GeezerVison is showing github.com — fix(composer): open @, #, $, and / menus after CJK full-width spaces … · patroza/t3code@57b0227
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/web/src/composer-logic.test.ts +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -269,6 +269,24 @@ describe("composerSubmissionIntentForKey", () => { | 269 | 269 | }); | 270 | 270 |
| 271 | 271 | describe("detectComposerTrigger", () => { | | 272 | + it.each(["\u3000", "\u00a0"])("detects completion after Unicode space %j", (space) => { | | 273 | + for (const [token, kind, query] of [ | | 274 | + ["@src", "path", "src"], | | 275 | + ["#123", "pull-request", "123"], | | 276 | + ["$review", "skill", "review"], | | 277 | + ["/model", "slash-command", "model"], | | 278 | + ]) { | | 279 | + const prefix = `日本語${space}`; | | 280 | + const text = `${prefix}${token}`; | | 281 | + expect(detectComposerTrigger(text, text.length)).toEqual({ | | 282 | + kind, | | 283 | + query, | | 284 | + rangeStart: prefix.length, | | 285 | + rangeEnd: text.length, | | 286 | + }); | | 287 | + } | | 288 | + }); | | 289 | + | 272 | 290 | it.each([ | 273 | 291 | ["Run /tmp/build.sh", "Run /tmp/build.sh".length], | 274 | 292 | ["/etc/hosts", "/etc/hosts".length], | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/composer-logic.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -109,7 +109,7 @@ function clampCursor(text: string, cursor: number): number { | 109 | 109 | } | 110 | 110 |
| 111 | 111 | function isWhitespace(char: string): boolean { | 112 | | - return char === " " || char === "\n" || char === "\t" || char === "\r"; | | 112 | + return /\s/.test(char); | 113 | 113 | } | 114 | 114 |
| 115 | 115 | function tokenStartForCursor(text: string, cursor: number): number { | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/src/composerTrigger.test.ts +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -25,6 +25,24 @@ function parsedLinkLabel(markdown: string): string | undefined { | 25 | 25 | } | 26 | 26 |
| 27 | 27 | describe("detectComposerTrigger", () => { | | 28 | + it.each(["\u3000", "\u00a0"])("detects completion after Unicode space %j", (space) => { | | 29 | + for (const [token, kind, query] of [ | | 30 | + ["@src", "path", "src"], | | 31 | + ["#123", "pull-request", "123"], | | 32 | + ["$review", "skill", "review"], | | 33 | + ["/model", "slash-command", "model"], | | 34 | + ]) { | | 35 | + const prefix = `日本語${space}`; | | 36 | + const text = `${prefix}${token}`; | | 37 | + expect(detectComposerTrigger(text, text.length)).toEqual({ | | 38 | + kind, | | 39 | + query, | | 40 | + rangeStart: prefix.length, | | 41 | + rangeEnd: text.length, | | 42 | + }); | | 43 | + } | | 44 | + }); | | 45 | + | 28 | 46 | it.each([ | 29 | 47 | ["Run /tmp/build.sh", "Run /tmp/build.sh".length], | 30 | 48 | ["/etc/hosts", "/etc/hosts".length], | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/src/composerTrigger.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -64,7 +64,7 @@ function clampCursor(text: string, cursor: number): number { | 64 | 64 | } | 65 | 65 |
| 66 | 66 | function isWhitespace(char: string): boolean { | 67 | | - return char === " " || char === "\n" || char === "\t" || char === "\r"; | | 67 | + return /\s/.test(char); | 68 | 68 | } | 69 | 69 |
| 70 | 70 | /** A second slash or backslash makes the whole word a path, even when the caret precedes it. */ | |
|