Skip to content

Commit 245df55

Browse files
committed
remove $ from regex
1 parent 7aa0d38 commit 245df55

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/features/terminal/utils.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ export async function waitForShellIntegration(terminal: Terminal): Promise<boole
4949
onDidWriteTerminalData((e) => {
5050
if (e.terminal === terminal) {
5151
dataSoFar += e.data;
52-
const lines = dataSoFar.split(/\r?\n/);
53-
const lastNonEmptyLine = lines.filter((line) => line.trim().length > 0).pop();
54-
if (lastNonEmptyLine && detectsCommonPromptPattern(lastNonEmptyLine)) {
52+
if (dataSoFar && detectsCommonPromptPattern(dataSoFar)) {
5553
resolve(false);
5654
}
5755
}
@@ -66,45 +64,40 @@ export async function waitForShellIntegration(terminal: Terminal): Promise<boole
6664
}
6765
}
6866

69-
/**
70-
* Detects if the given text content appears to end with a common prompt pattern.
71-
*
72-
* @param cursorLine The line to check for prompt patterns
73-
* @returns boolean indicating if a prompt pattern was detected
74-
*/
67+
// Detects if the given text content appears to end with a common prompt pattern.
7568
function detectsCommonPromptPattern(cursorLine: string): boolean {
7669
// PowerShell prompt: PS C:\> or similar patterns
77-
if (/PS\s+[A-Z]:\\.*>\s*$/.test(cursorLine)) {
70+
if (/PS\s+[A-Z]:\\.*>\s*/.test(cursorLine)) {
7871
return true;
7972
}
8073

8174
// Command Prompt: C:\path>
82-
if (/^[A-Z]:\\.*>\s*$/.test(cursorLine)) {
75+
if (/^[A-Z]:\\.*>\s*/.test(cursorLine)) {
8376
return true;
8477
}
8578

8679
// Bash-style prompts ending with $
87-
if (/\$\s*$/.test(cursorLine)) {
80+
if (/\$\s*/.test(cursorLine)) {
8881
return true;
8982
}
9083

9184
// Root prompts ending with #
92-
if (/#\s*$/.test(cursorLine)) {
85+
if (/#\s*/.test(cursorLine)) {
9386
return true;
9487
}
9588

9689
// Python REPL prompt
97-
if (/^>>>\s*$/.test(cursorLine)) {
90+
if (/^>>>\s*/.test(cursorLine)) {
9891
return true;
9992
}
10093

10194
// Custom prompts ending with the starship character (\u276f)
102-
if (/\u276f\s*$/.test(cursorLine)) {
95+
if (/\u276f\s*/.test(cursorLine)) {
10396
return true;
10497
}
10598

10699
// Generic prompts ending with common prompt characters
107-
if (/[>%]\s*$/.test(cursorLine)) {
100+
if (/[>%]\s*/.test(cursorLine)) {
108101
return true;
109102
}
110103

0 commit comments

Comments
 (0)