Skip to content

Commit 342ee0f

Browse files
committed
Propagate sub-search flag to display unmatched files across all search modes
- Carry forward the unmatched files from the immediately preceding search selection into nested sub-searches so they are displayed under the unmatched separator. E.g. if user is shown initially 40 results but selects 10 and runs nested search - if system matches 2 files, 8 should shown under 'unmatched' separator. If then user selects 5, but only 1 matches, 4 files should be shown under separator, and so on. └── apps └── editor └── src ├── commands │ └── search-files-commands │ ├── index.ts │ ├── search-files-commands.ts │ └── utils │ ├── get-target-folder-path.ts │ └── prompt-for-provided-results.ts └── features └── search-files ├── index.ts ├── search-files.ts ├── search-modes │ ├── perform-agent-search-mode │ │ ├── agents │ │ │ ├── antigravity.ts │ │ │ ├── claude.ts │ │ │ ├── codex.ts │ │ │ ├── cursor.ts │ │ │ ├── grok.ts │ │ │ ├── muse.ts │ │ │ └── opencode.ts │ │ ├── index.ts │ │ ├── perform-agent-search-mode.ts │ │ ├── types.ts │ │ └── utils.ts │ ├── perform-intelligent-search-mode.ts │ ├── perform-keywords-search-mode.ts │ └── perform-phrase-search-mode.ts └── utils ├── analyze-files.ts ├── check-matches-condition.ts ├── create-search-regex.ts ├── group-quick-pick-items.ts ├── handle-parent-folder-result.ts ├── map-files-to-quick-pick-items.ts ├── prompt-for-config.ts ├── prompt-for-intelligent-search-results.ts ├── prompt-for-keywords-match-mode.ts ├── prompt-for-keywords-target.ts ├── prompt-for-search-mode.ts ├── prompt-for-search-results.ts ├── prompt-for-search-term.ts ├── prompt-for-shrink-mode.ts ├── search-files-by-intelligent.ts ├── search-files-by-keywords.ts ├── search-files-by-phrase.ts └── show-search-results-quick-pick.ts
1 parent 5d67627 commit 342ee0f

7 files changed

Lines changed: 34 additions & 11 deletions

File tree

‎apps/editor/src/features/search-files/search-files.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ export const search_files = async (params: {
8181
extension_context: params.extension_context,
8282
show_back_button: params.show_back_button,
8383
search_in_results,
84-
is_search_in_selected: params.is_search_in_selected
84+
is_search_in_selected: params.is_search_in_selected,
85+
is_sub_search: params.is_sub_search
8586
}
8687

8788
if (search_mode == 'phrase') {
@@ -98,15 +99,18 @@ export const search_files = async (params: {
9899
show_back_button: params.show_back_button,
99100
search_in_results,
100101
is_search_in_selected: params.is_search_in_selected,
102+
is_sub_search: params.is_sub_search,
101103
folder_path: params.folder_path
102104
})
103105
} else if (search_mode == 'agent') {
104106
flow_result = await perform_agent_search_mode({
107+
resolve_files,
105108
workspace_provider: params.workspace_provider,
106109
extension_context: params.extension_context,
107110
show_back_button: params.show_back_button,
108111
search_in_results,
109-
is_search_in_selected: params.is_search_in_selected
112+
is_search_in_selected: params.is_search_in_selected,
113+
is_sub_search: params.is_sub_search
110114
})
111115
}
112116

‎apps/editor/src/features/search-files/search-modes/perform-agent-search-mode/perform-agent-search-mode.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const AGENTS: CodingAgent[] = [
3434
]
3535

3636
export const perform_agent_search_mode = async (params: {
37+
resolve_files: () => Promise<string[]>
3738
workspace_provider: WorkspaceProvider
3839
extension_context: vscode.ExtensionContext
3940
show_back_button?: boolean
@@ -45,6 +46,7 @@ export const perform_agent_search_mode = async (params: {
4546
| 'back'
4647
>
4748
is_search_in_selected?: boolean
49+
is_sub_search?: boolean
4850
}): Promise<
4951
| { selected_paths: string[]; matched_paths: string[]; title: string }
5052
| undefined
@@ -638,6 +640,8 @@ export const perform_agent_search_mode = async (params: {
638640
break
639641
}
640642

643+
const input_files = await params.resolve_files()
644+
641645
let should_go_back_to_workspace = false
642646
let restored_selected_paths: string[] | undefined = undefined
643647
let restored_unmatched_paths: string[] | undefined = undefined
@@ -650,8 +654,12 @@ export const perform_agent_search_mode = async (params: {
650654
params.workspace_provider.get_checked_files()
651655
const unmatched_checked_files =
652656
restored_unmatched_paths ??
653-
(params.is_search_in_selected
654-
? currently_checked.filter((f) => !absolute_paths.includes(f))
657+
(params.is_search_in_selected || params.is_sub_search
658+
? input_files.filter(
659+
(f) =>
660+
(params.is_sub_search || currently_checked.includes(f)) &&
661+
!absolute_paths.includes(f)
662+
)
655663
: [])
656664

657665
const selected_items = (await show_search_results_quick_pick({

‎apps/editor/src/features/search-files/search-modes/perform-intelligent-search-mode.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const perform_intelligent_search_mode = async (params: {
3939
>
4040
show_back_button?: boolean
4141
is_search_in_selected?: boolean
42+
is_sub_search?: boolean
4243
folder_path?: string
4344
}): Promise<
4445
| { selected_paths: string[]; matched_paths: string[]; title: string }
@@ -457,7 +458,8 @@ export const perform_intelligent_search_mode = async (params: {
457458
workspace_provider: params.workspace_provider,
458459
restored_selected_paths,
459460
restored_unmatched_paths,
460-
is_search_in_selected: params.is_search_in_selected
461+
is_search_in_selected: params.is_search_in_selected,
462+
is_sub_search: params.is_sub_search
461463
})
462464

463465
if (apply_result == 'back') {

‎apps/editor/src/features/search-files/search-modes/perform-keywords-search-mode.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const perform_keywords_search_mode = async (params: {
2626
| 'back'
2727
>
2828
is_search_in_selected?: boolean
29+
is_sub_search?: boolean
2930
}): Promise<
3031
| { selected_paths: string[]; matched_paths: string[]; title: string }
3132
| undefined
@@ -203,7 +204,8 @@ export const perform_keywords_search_mode = async (params: {
203204
workspace_provider: params.workspace_provider,
204205
restored_selected_paths,
205206
restored_unmatched_paths,
206-
is_search_in_selected: params.is_search_in_selected
207+
is_search_in_selected: params.is_search_in_selected,
208+
is_sub_search: params.is_sub_search
207209
})
208210

209211
if (selected_items == 'back') {

‎apps/editor/src/features/search-files/search-modes/perform-phrase-search-mode.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const perform_phrase_search_mode = async (params: {
1919
| 'back'
2020
>
2121
is_search_in_selected?: boolean
22+
is_sub_search?: boolean
2223
}): Promise<
2324
| { selected_paths: string[]; matched_paths: string[]; title: string }
2425
| undefined
@@ -122,7 +123,8 @@ export const perform_phrase_search_mode = async (params: {
122123
workspace_provider: params.workspace_provider,
123124
restored_selected_paths,
124125
restored_unmatched_paths,
125-
is_search_in_selected: params.is_search_in_selected
126+
is_search_in_selected: params.is_search_in_selected,
127+
is_sub_search: params.is_sub_search
126128
})
127129

128130
if (selected_items == 'back') {

‎apps/editor/src/features/search-files/utils/prompt-for-intelligent-search-results.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const prompt_for_intelligent_search_results = async (params: {
1212
restored_selected_paths?: string[]
1313
restored_unmatched_paths?: string[]
1414
is_search_in_selected?: boolean
15+
is_sub_search?: boolean
1516
}): Promise<
1617
| { selected_paths: string[]; matched_paths: string[]; title: string }
1718
| {
@@ -51,9 +52,11 @@ export const prompt_for_intelligent_search_results = async (params: {
5152

5253
const unmatched_checked_files =
5354
params.restored_unmatched_paths ??
54-
(params.is_search_in_selected
55+
(params.is_search_in_selected || params.is_sub_search
5556
? params.files.filter(
56-
(f) => currently_checked.includes(f) && !unique_paths.includes(f)
57+
(f) =>
58+
(params.is_sub_search || currently_checked.includes(f)) &&
59+
!unique_paths.includes(f)
5760
)
5861
: [])
5962

‎apps/editor/src/features/search-files/utils/prompt-for-search-results.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const prompt_for_search_results = async (params: {
1212
restored_selected_paths?: string[]
1313
restored_unmatched_paths?: string[]
1414
is_search_in_selected?: boolean
15+
is_sub_search?: boolean
1516
}): Promise<
1617
| { selected_paths: string[]; matched_paths: string[]; title: string }
1718
| {
@@ -27,10 +28,11 @@ export const prompt_for_search_results = async (params: {
2728

2829
const unmatched_checked_files =
2930
params.restored_unmatched_paths ??
30-
(params.is_search_in_selected
31+
(params.is_search_in_selected || params.is_sub_search
3132
? params.files.filter(
3233
(f) =>
33-
currently_checked.includes(f) && !params.matched_files.includes(f)
34+
(params.is_sub_search || currently_checked.includes(f)) &&
35+
!params.matched_files.includes(f)
3436
)
3537
: [])
3638

0 commit comments

Comments
 (0)