Skip to content

Commit 1c45ba3

Browse files
committed
Improve keyword search navigation and filter invalid tokens
- keyword search for queries with "-" prefix enter infinite loop - is the code handling "-" prefix and empty space correctly (ignoring keyword) or it enters infinte loop? └── apps └── editor └── src └── features └── search-files ├── index.ts ├── search-files.ts ├── search-modes │ ├── perform-intelligent-search-mode.ts │ ├── perform-keywords-search-mode.ts │ ├── perform-phrase-search-mode.ts │ └── perform-semantic-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 └── search-files-by-semantic.ts
1 parent 075e0b6 commit 1c45ba3

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const perform_keywords_search_mode = async (params: {
9999
while (true) {
100100
const keywords = (
101101
search_term.match(/(?:-?"[^"]*")|(?:-?[^\s,]+)/g) || []
102-
).filter((k) => k.length > 0)
102+
).filter((k) => k.length > 0 && k != '-' && k != '""' && k != '-""')
103103

104104
const positive_keywords = keywords.filter((k) => !k.startsWith('-'))
105105

@@ -171,13 +171,21 @@ export const perform_keywords_search_mode = async (params: {
171171
}
172172

173173
if (is_cancelled) {
174+
if (positive_keywords.length <= 1) {
175+
go_back_to_target = true
176+
break
177+
}
174178
continue
175179
}
176180

177181
if (matched_files.length == 0) {
178182
vscode.window.showInformationMessage(
179183
t('feature.search-files.no-files')
180184
)
185+
if (positive_keywords.length <= 1) {
186+
go_back_to_target = true
187+
break
188+
}
181189
continue
182190
}
183191

0 commit comments

Comments
 (0)