jhorvath commented on code in PR #8000:
URL: https://github.com/apache/netbeans/pull/8000#discussion_r1878296290
##########
java/java.lsp.server/vscode/src/extension.ts:
##########
@@ -377,6 +377,107 @@ function getValueAfterPrefix(input: string | undefined,
prefix: string): string
return '';
}
+class LineBufferingPseudoterminal implements vscode.Pseudoterminal {
+ private static instances = new Map<string, LineBufferingPseudoterminal>();
+
+ private writeEmitter = new vscode.EventEmitter<string>();
+ onDidWrite: vscode.Event<string> = this.writeEmitter.event;
+
+ private closeEmitter = new vscode.EventEmitter<void>();
+ onDidClose?: vscode.Event<void> = this.closeEmitter.event;
+
+ private buffer: string = '';
+ private isOpen = false;
+ private readonly name: string;
+ private terminal: vscode.Terminal | undefined;
+
+ private constructor(name: string) {
+ this.name = name;
+ }
+
+ open(): void {
+ this.isOpen = true;
+ }
+
+ close(): void {
+ this.isOpen = false;
+ this.closeEmitter.fire();
+ }
+
+ /**
+ * Accepts partial input strings and logs complete lines when they are
formed.
+ * Also processes carriage returns (\r) to overwrite the current line.
+ * @param input The string input to the pseudoterminal.
+ */
+ public acceptInput(input: string): void {
+ if (!this.isOpen) {
+ return;
+ }
+
+ for (const char of input) {
+ if (char === '\n') {
+ // Process a newline: log the current buffer and reset it
+ this.logLine(this.buffer.trim());
+ this.buffer = '';
+ } else if (char === '\r') {
+ // Process a carriage return: log the current buffer on the
same line
+ this.logInline(this.buffer.trim());
Review Comment:
`EventEmitter.fire(string)` always adds new line. We have to buffer whole
lines because of it. There were unexpected line breaks with no buffering.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists