Skip to content

Commit 8fc6f86

Browse files
gselzerclaude
andcommitted
code-lsp: keep ScriptSession's environment Optional
Empty means no server has been launched yet. A blank Environment in its place equals the environment of most scripts, so follow() never launched their first server, failing LanguageServersTest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent cf28ca5 commit 8fc6f86

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎scijava-code-lsp/src/main/java/org/scijava/code/lsp/ScriptSession.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public final class ScriptSession implements AutoCloseable {
117117
private CompletableFuture<Optional<LanguageServer>> server =
118118
CompletableFuture.completedFuture(Optional.empty());
119119
/** Where the script runs, as the server is launched for. */
120-
private Environment environment = new Environment();
120+
private Optional<Environment> environment = Optional.empty();
121121
/** How many servers were moved to: which one is meant, as of now. */
122122
private int generation;
123123
/** The server whose messages are heard (set as it is launched). */
@@ -453,8 +453,8 @@ private static boolean isAccessible(final Class<?> c) {
453453
*/
454454
private boolean follow() {
455455
final Environment env = doc.environment(file.get());
456-
if (closed || environment.equals(env)) return false;
457-
environment = env;
456+
if (closed || environment.equals(Optional.of(env))) return false;
457+
environment = Optional.of(env);
458458
generation++;
459459
server = server.thenApplyAsync(old -> {
460460
old.ifPresent(this::stop);

0 commit comments

Comments
 (0)