Skip to content

Commit

Permalink
Fixing the build output appearence in vscode
Browse files Browse the repository at this point in the history
  • Loading branch information
jhorvath committed Jan 9, 2025
1 parent cb84370 commit c615560
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,23 @@ public final Lookup getIOLookup(LspIO io) {

@Override
public final void resetIO(LspIO io) {
NbCodeLanguageClient client = LspServerUtils.findLspClient(Lookup.getDefault());
NbCodeLanguageClient client = io.getClient();
if (client != null) {
client.resetOutput(io.name);
}
}

@Override
public final void showIO(LspIO io, Set<ShowOperation> operations) {
NbCodeLanguageClient client = LspServerUtils.findLspClient(Lookup.getDefault());
NbCodeLanguageClient client = io.getClient();
if (client != null) {
client.showOutput(io.name);
}
}

@Override
public final void closeIO(LspIO io) {
NbCodeLanguageClient client = LspServerUtils.findLspClient(Lookup.getDefault());
NbCodeLanguageClient client = io.getClient();
if (client != null) {
client.closeOutput(io.name);
}
Expand Down Expand Up @@ -180,9 +180,14 @@ public void close() {
};
}
this.in = in;
client = LspServerUtils.findLspClient(Lookup.getDefault());
if (client != null) {
client.resetOutput(name);
// In case of Run, Debug and Test use IOContext for output. IOContext will end up in the Debug Console
if (!(name.startsWith("Run") || name.startsWith("Debug") || name.startsWith("Test"))) { //NOI18N
client = LspServerUtils.findLspClient(Lookup.getDefault());
if (client != null) {
client.resetOutput(name);
}
} else {
client = null;
}
}

Expand All @@ -201,8 +206,16 @@ private final class LspWriter extends Writer {
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
String chunk = new String(cbuf, off, len);
if (len > 0) {
client.writeOutput(new OutputMessage(name, chunk, stdIO));
if (client != null) {
if (len > 0) {
client.writeOutput(new OutputMessage(name, chunk, stdIO));
}
} else {
if (stdIO) {
ctx.stdOut(chunk);
} else {
ctx.stdErr(chunk);
}
}
}

Expand All @@ -215,6 +228,13 @@ public void close() throws IOException {
closed = true;
}
}

protected NbCodeLanguageClient getClient() {
return client;
}
}

// private static boolean namedOutput(String name) {
// return !(name.startsWith("Run") || name.startsWith("Debug"));
// }
}
11 changes: 9 additions & 2 deletions java/java.lsp.server/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,18 @@ class LineBufferingPseudoterminal implements vscode.Pseudoterminal {
name: this.name,
pty: this,
});

// Listen for terminal close events
vscode.window.onDidCloseTerminal((closedTerminal) => {
if (closedTerminal === this.terminal) {
this.terminal = undefined; // Clear the terminal reference
}
});
}
// Prevent 'stealing' of the focus when running tests in parallel
if (!testAdapter?.testInParallelProfileExist()) {
// if (!testAdapter?.testInParallelProfileExist()) {
this.terminal.show(true);
}
// }
}

/**
Expand Down

0 comments on commit c615560

Please sign in to comment.