Skip to content

Commit 6d80b64

Browse files
committed
Refine chat input regular expressions to correctly parse filenames and keywords by removing the colon delimiter
1 parent c1d95bf commit 6d80b64

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎packages/ui/src/components/editor/panel/ChatInput/ChatInput.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
227227
// Check if cursor is at the end of a shortened filename
228228
const text_before_cursor = value.substring(0, caret_position)
229229
const filename_match = text_before_cursor.match(
230-
/([^\s,;:.!?`]*\.[^\s,;:.!?`]+)$/
230+
/([^\s,;:!?`]*\.[^\s,;:!?`]+)$/
231231
)
232232

233233
if (filename_match) {
@@ -385,7 +385,7 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
385385
if (cursor_pos > 0) {
386386
const text_before = display_value.substring(0, cursor_pos)
387387
const filename_match = text_before.match(
388-
/([^\s,;:.!?`]*\.[^\s,;:.!?`]+)$/
388+
/([^\s,;:!?`]*\.[^\s,;:!?`]+)$/
389389
)
390390

391391
if (filename_match) {

‎packages/ui/src/components/editor/panel/ChatInput/hooks/use-handlers.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const use_handlers = (props: ChatInputProps) => {
8282
const words = new_display_value.split(/(\s+)/)
8383
const converted_words = words.map((word) => {
8484
// Check if this looks like a filename
85-
if (/^[^\s,;:.!?]*\.[^\s,;:.!?]+$/.test(word)) {
85+
if (/^[^\s,;:!?`]*\.[^\s,;:!?`]+$/.test(word)) {
8686
// Check if any context path ends with this filename
8787
const matching_path = context_file_paths.find(
8888
(path) => path.endsWith('/' + word) || path === word

‎packages/ui/src/components/editor/panel/ChatInput/utils/get-highlighted-text.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const get_highlighted_text = (params: {
3434
}
3535

3636
const regex =
37-
/(#Selection|#Changes:[^\s,;:.!?]+(?:\/[^\s,;:.!?]+)?|#SavedContext:(?:WorkspaceState|JSON)\s+"[^"]+")/g
37+
/(#Selection|#Changes:[^\s,;:!?]+|#SavedContext:(?:WorkspaceState|JSON)\s+"[^"]+")/g
3838
const parts = params.text.split(regex)
3939

4040
return parts
@@ -45,7 +45,7 @@ export const get_highlighted_text = (params: {
4545
})
4646
return `<span class="${className}">${escape_html(part)}</span>`
4747
}
48-
if (part && /^#Changes:[^\s,;:.!?]+(?:\/[^\s,;:.!?]+)?$/.test(part)) {
48+
if (part && /^#Changes:[^\s,;:!?]+$/.test(part)) {
4949
return `<span class="${styles['selection-keyword']}">${escape_html(
5050
part
5151
)}</span>`
@@ -59,7 +59,7 @@ export const get_highlighted_text = (params: {
5959
)}</span>`
6060
}
6161

62-
const filename_regex = /([^\s,;:.!?`]*\.[^\s,;:.!?`]+)/g
62+
const filename_regex = /([^\s,;:!?`]*\.[^\s,;:!?`]+)/g
6363
return part
6464
.split(filename_regex)
6565
.map((sub_part, index) => {

‎packages/vscode/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat",
44
"description": "AI coding without agents (CWC)",
5-
"version": "1.535.0",
5+
"version": "1.536.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "rimraf out && npm run compile",

0 commit comments

Comments
 (0)