Skip to content

Commit 1d93379

Browse files
committed
Refine @ sign detection logic to trigger quick pick on non-word characters, and remove redundant context file updates in the VS Code panel provider
1 parent 11818e4 commit 1d93379

4 files changed

Lines changed: 9 additions & 10 deletions

File tree

‎packages/ui/src/components/editor/common/Icon/Icon.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import CodeWebChatLogo from '../../../../assets/icons/code-web-chat-logo.svg'
88
import CodeWebChatText from '../../../../assets/icons/code-web-chat-text.svg'
99
import Copilot from '../../../../assets/icons/copilot.svg'
1010
import CurlyBraces from '../../../../assets/icons/curly-braces.svg'
11-
import GithubCopilot from '../../../../assets/icons/github-copilot.svg'
1211
import DeepSeek from '../../../../assets/icons/deepseek.svg'
12+
import GithubCopilot from '../../../../assets/icons/github-copilot.svg'
1313
import DiscordLogo from '../../../../assets/icons/discord-logo.svg'
1414
import DiscordText from '../../../../assets/icons/discord-text.svg'
1515
import Doubao from '../../../../assets/icons/doubao.svg'

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,14 @@ export const use_handlers = (
438438

439439
if (char_before_caret == '@') {
440440
const is_at_start = caret_position == 1
441-
const is_after_space =
442-
caret_position > 1 &&
443-
/\s/.test(new_display_value.charAt(caret_position - 2))
441+
let is_after_non_word_char = false
442+
if (caret_position > 1) {
443+
const char_before_at = new_display_value.charAt(caret_position - 2)
444+
// Check if the character before '@' is not a word character (a-z, A-Z, 0-9, _)
445+
is_after_non_word_char = !/\w/.test(char_before_at)
446+
}
444447

445-
if (is_at_start || is_after_space) {
448+
if (is_at_start || is_after_non_word_char) {
446449
props.on_at_sign_click()
447450
}
448451
} else if (char_before_caret == '#') {

‎packages/vscode/src/views/panel/backend/panel-provider.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,9 @@ export class PanelProvider implements vscode.WebviewViewProvider {
266266
token_count_emitter.on('token-count-updated', () => {
267267
if (this._webview_view) {
268268
this.calculate_token_count()
269+
this.send_context_files()
269270
}
270271
})
271-
this.workspace_provider.onDidChangeCheckedFiles(() =>
272-
this.send_context_files()
273-
)
274272

275273
this.context.subscriptions.push(this._config_listener)
276274

@@ -622,7 +620,6 @@ export class PanelProvider implements vscode.WebviewViewProvider {
622620
command: 'CAN_UNDO_CHANGED',
623621
can_undo: this._can_undo()
624622
})
625-
this.send_context_files()
626623
}, 1000)
627624
}
628625

‎packages/vscode/src/views/panel/frontend/Main/MainView/MainView.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useEffect } from 'react'
21
import styles from './MainView.module.scss'
32
import { Configurations as UiConfigurations } from '@ui/components/editor/panel/Configurations'
43
import { Presets as UiPresets } from '@ui/components/editor/panel/Presets'

0 commit comments

Comments
 (0)