Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/shared/src/composerTrigger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ describe("detectComposerTrigger", () => {
["Run /tmp/build.sh", "Run /tmp/build.sh".length],
["/etc/hosts", "/etc/hosts".length],
["Use /etc/hosts now", "Use /et".length],
["cmd /foo\\bar", "cmd /foo\\bar".length],
["/Windows\\System32", "/Windows\\System32".length],
])("keeps the path in %j out of the slash menu", (text, cursor) => {
expect(detectComposerTrigger(text, cursor)).toBeNull();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/composerTrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function isWhitespace(char: string): boolean {
return char === " " || char === "\n" || char === "\t" || char === "\r";
}

/** A second slash makes the whole word a path, even when the caret precedes that slash. */
/** A second slash or backslash makes the whole word a path, even when the caret precedes it. */
export function isPathWord(
text: string,
wordStart: number,
Expand All @@ -56,7 +56,7 @@ export function isPathWord(
while (wordEnd < text.length && !isWhitespaceChar(text[wordEnd] ?? "")) {
wordEnd += 1;
}
return text.slice(wordStart + 1, wordEnd).includes("/");
return /[/\\]/.test(text.slice(wordStart + 1, wordEnd));
}

/**
Expand Down
Loading