Skip to content

Commit 8a288aa

Browse files
committed
Report continuation prompt in bash
1 parent 11014ec commit 8a288aa

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
112112
return;
113113
}
114114

115-
// TODO: Support multi-line prompts
116-
117115
this._value = commandLine.substring(this._commandStartX);
118116
this._cursorIndex = Math.max(buffer.cursorX - this._commandStartX, 0);
119117

src/vs/platform/terminal/common/xterm/shellIntegrationAddon.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,12 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
382382
}
383383
switch (key) {
384384
case 'ContinuationPrompt': {
385-
this._updateContinuationPrompt(value);
385+
// Exclude escape sequences and values between \[ and \]
386+
const sanitizedValue = (value
387+
.replace(/\x1b\[[0-9;]*m/g, '')
388+
.replace(/\\\[.*?\\\]/g, '')
389+
);
390+
this._updateContinuationPrompt(sanitizedValue);
386391
return true;
387392
}
388393
case 'Cwd': {
@@ -411,8 +416,10 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
411416
}
412417

413418
private _updateContinuationPrompt(value: string) {
414-
const commandDetection = this.capabilities.get(TerminalCapability.CommandDetection);
415-
commandDetection?.setContinuationPrompt(value);
419+
if (!this._terminal) {
420+
return;
421+
}
422+
this._createOrGetCommandDetection(this._terminal).setContinuationPrompt(value);
416423
}
417424

418425
private _updateCwd(value: string) {

src/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ __vsc_current_command=""
162162
__vsc_nonce="$VSCODE_NONCE"
163163
unset VSCODE_NONCE
164164

165+
# Report continuation prompt
166+
builtin printf "\e]633;P;ContinuationPrompt=$(echo "$PS2" | sed 's/\x1b/\\\\x1b/g')\a"
167+
165168
__vsc_prompt_start() {
166169
builtin printf '\e]633;A\a'
167170
}

0 commit comments

Comments
 (0)