Skip to content

Commit 55fd339

Browse files
committed
Update QuickPick placeholder text and improve search input handling with whole-word matching support
1 parent 8ae60b3 commit 55fd339

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

‎apps/editor/src/commands/rate-command.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function rate_command() {
2020
const quick_pick = vscode.window.createQuickPick<(typeof options)[0]>()
2121
quick_pick.items = options
2222
quick_pick.title = 'Rate Extension'
23-
quick_pick.placeholder = 'Select platform'
23+
quick_pick.placeholder = 'Select a platform'
2424
quick_pick.buttons = [
2525
{
2626
iconPath: new vscode.ThemeIcon('close'),

‎apps/editor/src/commands/search-files-for-context-command.ts‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,18 @@ export const search_files_for_context_commands = (
4444
iconPath: new vscode.ThemeIcon('close'),
4545
tooltip: 'Close'
4646
}
47+
4748
input_box.buttons = [close_button]
4849

49-
const keywords_input = await new Promise<string | undefined>(
50+
const result = await new Promise<{ value: string | undefined }>(
5051
(resolve) => {
5152
let is_resolved = false
5253
const disposables: vscode.Disposable[] = []
5354

5455
disposables.push(
5556
input_box.onDidTriggerButton((button) => {
5657
if (button === close_button) {
57-
resolve(undefined)
58+
resolve({ value: undefined })
5859
input_box.hide()
5960
}
6061
}),
@@ -65,7 +66,7 @@ export const search_files_for_context_commands = (
6566
return
6667
}
6768
is_resolved = true
68-
resolve(value)
69+
resolve({ value })
6970
input_box.hide()
7071
}),
7172
input_box.onDidChangeValue(() => {
@@ -75,7 +76,7 @@ export const search_files_for_context_commands = (
7576
}),
7677
input_box.onDidHide(() => {
7778
if (!is_resolved) {
78-
resolve(undefined)
79+
resolve({ value: undefined })
7980
}
8081
disposables.forEach((d) => d.dispose())
8182
input_box.dispose()
@@ -85,6 +86,7 @@ export const search_files_for_context_commands = (
8586
}
8687
)
8788

89+
const keywords_input = result.value
8890
if (!keywords_input) return
8991

9092
await extension_context.workspaceState.update(
@@ -347,8 +349,25 @@ const search_files_by_keywords = async (params: {
347349
}): Promise<string[]> => {
348350
const matched_files: string[] = []
349351

350-
const escaped_term = params.search_term.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
351-
const pattern = escaped_term.replace(/\s+/g, '\\s+')
352+
let actual_term = params.search_term
353+
let match_whole_word = false
354+
355+
if (
356+
actual_term.length >= 2 &&
357+
actual_term.startsWith('"') &&
358+
actual_term.endsWith('"')
359+
) {
360+
match_whole_word = true
361+
actual_term = actual_term.slice(1, -1)
362+
}
363+
364+
const escaped_term = actual_term.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
365+
let pattern = escaped_term.replace(/\s+/g, '\\s+')
366+
367+
if (match_whole_word) {
368+
pattern = `\\b${pattern}\\b`
369+
}
370+
352371
const regex = new RegExp(pattern, 'mi')
353372

354373
for (const file_path of params.files) {

0 commit comments

Comments
 (0)