Skip to content

Commit 856d647

Browse files
committed
Make lines below cursor require continuation
1 parent 432af8d commit 856d647

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,14 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
113113
return;
114114
}
115115

116+
// Command start line
116117
this._value = commandLine.substring(this._commandStartX);
117118
this._cursorIndex = Math.max(buffer.cursorX - this._commandStartX, 0);
118119

119120
// IDEA: Reinforce knowledge of prompt to avoid incorrect commandStart
120121
// IDEA: Detect ghost text based on SGR and cursor
121122

122-
// Add multi-lines
123+
// From command start line to cursor line
123124
const absoluteCursorY = buffer.baseY + buffer.cursorY;
124125
for (let y = commandStartY + 1; y <= absoluteCursorY; y++) {
125126
let lineText = buffer.getLine(y)?.translateToString(true);
@@ -140,13 +141,15 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
140141
}
141142
}
142143

143-
// Check lines below the cursor for continuations
144+
// Below cursor line
144145
for (let y = absoluteCursorY + 1; y < buffer.baseY + this._xterm.rows; y++) {
145146
const lineText = buffer.getLine(y)?.translateToString(true);
146-
if (lineText && this._lineContainsContinuationPrompt(lineText)) {
147-
this._value += `\n${this._trimContinuationPrompt(lineText)}`;
148-
} else {
149-
break;
147+
if (lineText) {
148+
if (this._continuationPrompt === undefined || this._lineContainsContinuationPrompt(lineText)) {
149+
this._value += `\n${this._trimContinuationPrompt(lineText)}`;
150+
} else {
151+
break;
152+
}
150153
}
151154
}
152155

0 commit comments

Comments
 (0)