Skip to content

Commit 55917d4

Browse files
committed
Maintain separate search mode state for selected files search
- move undo/redo selection into 'more actions' in Workspace pane (place on top, with added separator line below) - review how items are numbered so they start from lowest value possible - Separate the last-used search mode state keys for workspace search and selected files search so each entry point remembers and highlights its own previously selected mode independently. └── apps └── editor ├── package.json └── src ├── commands │ └── search-files-commands │ ├── index.ts │ ├── search-files-commands.ts │ └── utils │ ├── get-target-folder-path.ts │ └── prompt-for-provided-results.ts ├── constants │ └── state-keys.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 6cdc883 commit 55917d4

3 files changed

Lines changed: 47 additions & 38 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -607,32 +607,37 @@
607607
{
608608
"command": "codeWebChat.searchSelectedFiles",
609609
"when": "view == codeWebChatViewSelectedFiles",
610-
"group": "navigation@2"
610+
"group": "navigation@1"
611611
},
612612
{
613613
"command": "codeWebChat.undoSelection",
614-
"when": "view == codeWebChatViewSelectedFiles",
615-
"group": "navigation@3"
614+
"when": "view == codeWebChatViewWorkspace",
615+
"group": "1_more@1"
616+
},
617+
{
618+
"command": "codeWebChat.redoSelection",
619+
"when": "view == codeWebChatViewWorkspace",
620+
"group": "1_more@2"
616621
},
617622
{
618623
"command": "codeWebChat.restoreFileSelection",
619624
"when": "view == codeWebChatViewSelectedFiles",
620-
"group": "navigation@4"
625+
"group": "navigation@2"
621626
},
622627
{
623628
"command": "codeWebChat.saveFileSelection",
624629
"when": "view == codeWebChatViewSelectedFiles",
625-
"group": "navigation@5"
630+
"group": "navigation@3"
626631
},
627632
{
628633
"command": "codeWebChat.expandContextFolders",
629634
"when": "view == codeWebChatViewSelectedFiles",
630-
"group": "navigation@6"
635+
"group": "navigation@4"
631636
},
632637
{
633638
"command": "codeWebChat.collapseContextFolders",
634639
"when": "view == codeWebChatViewSelectedFiles",
635-
"group": "navigation@7"
640+
"group": "navigation@5"
636641
},
637642
{
638643
"command": "codeWebChat.copyMarkdown",
@@ -654,60 +659,55 @@
654659
"when": "view == codeWebChatViewSelectedFiles",
655660
"group": "2_more@2"
656661
},
657-
{
658-
"command": "codeWebChat.redoSelection",
659-
"when": "view == codeWebChatViewSelectedFiles",
660-
"group": "3_more@1"
661-
},
662662
{
663663
"command": "codeWebChat.searchFilesWorkspaceAction",
664664
"when": "view == codeWebChatViewWorkspace",
665-
"group": "navigation@5"
665+
"group": "navigation@1"
666666
},
667667
{
668668
"command": "codeWebChat.clearChecks",
669669
"when": "view == codeWebChatViewWorkspace",
670-
"group": "navigation@6"
670+
"group": "navigation@2"
671671
},
672672
{
673673
"command": "codeWebChat.newFile",
674674
"when": "view == codeWebChatViewWorkspace",
675-
"group": "navigation@7"
675+
"group": "navigation@3"
676676
},
677677
{
678678
"command": "codeWebChat.newFolder",
679679
"when": "view == codeWebChatViewWorkspace",
680-
"group": "navigation@8"
680+
"group": "navigation@4"
681681
},
682682
{
683683
"command": "codeWebChat.collapseWorkspaceFolders",
684684
"when": "view == codeWebChatViewWorkspace",
685-
"group": "navigation@9"
685+
"group": "navigation@5"
686686
},
687687
{
688688
"command": "codeWebChat.selectWorkspaceFile",
689689
"when": "view == codeWebChatViewWorkspace",
690-
"group": "3_more@1"
690+
"group": "2_more@1"
691691
},
692692
{
693693
"command": "codeWebChat.selectClipboardPaths",
694694
"when": "view == codeWebChatViewWorkspace",
695-
"group": "3_more@2"
695+
"group": "2_more@2"
696696
},
697697
{
698698
"command": "codeWebChat.selectModifiedFiles",
699699
"when": "view == codeWebChatViewWorkspace",
700-
"group": "3_more@3"
700+
"group": "2_more@3"
701701
},
702702
{
703703
"command": "codeWebChat.selectFilesOfCommit",
704704
"when": "view == codeWebChatViewWorkspace",
705-
"group": "3_more@4"
705+
"group": "2_more@4"
706706
},
707707
{
708708
"command": "codeWebChat.duplicateWorkspace",
709709
"when": "view == codeWebChatViewWorkspace",
710-
"group": "4_more@1"
710+
"group": "3_more@1"
711711
},
712712
{
713713
"command": "codeWebChat.checkAllOpenEditors",
@@ -717,27 +717,27 @@
717717
{
718718
"command": "codeWebChat.copyMarkdownOpenEditors",
719719
"when": "view == codeWebChatViewOpenEditors",
720-
"group": "2_more@1"
720+
"group": "1_more@1"
721721
},
722722
{
723723
"command": "codeWebChat.saveAll",
724724
"when": "view == codeWebChatViewOpenEditors",
725-
"group": "navigation@5"
725+
"group": "navigation@2"
726726
},
727727
{
728728
"command": "codeWebChat.copyPathsOpenEditors",
729729
"when": "view == codeWebChatViewOpenEditors",
730-
"group": "2_more@2"
730+
"group": "1_more@2"
731731
},
732732
{
733733
"command": "codeWebChat.closeAllEditors",
734734
"when": "view == codeWebChatViewOpenEditors",
735-
"group": "navigation@6"
735+
"group": "navigation@3"
736736
},
737737
{
738738
"command": "codeWebChat.settings",
739739
"when": "view == promptView",
740-
"group": "navigation@2"
740+
"group": "navigation@1"
741741
},
742742
{
743743
"command": "codeWebChat.visitWebsite",
@@ -803,17 +803,17 @@
803803
{
804804
"command": "codeWebChat.selectParentFolder",
805805
"when": "view == codeWebChatViewOpenEditors && viewItem == openEditor",
806-
"group": "2_modification@2"
806+
"group": "2_modification@1"
807807
},
808808
{
809809
"command": "codeWebChat.selectReferencingFiles",
810810
"when": "view == codeWebChatViewOpenEditors && viewItem == openEditor",
811-
"group": "2_modification@3"
811+
"group": "2_modification@2"
812812
},
813813
{
814814
"command": "codeWebChat.selectImportedFiles",
815815
"when": "view == codeWebChatViewOpenEditors && viewItem == openEditor",
816-
"group": "2_modification@4"
816+
"group": "2_modification@3"
817817
},
818818
{
819819
"command": "codeWebChat.setRanges",
@@ -853,27 +853,27 @@
853853
{
854854
"command": "codeWebChat.searchFilesFromDirectory",
855855
"when": "view == codeWebChatViewWorkspace && (viewItem == directory || viewItem == workspaceRoot || viewItem == contextDirectory || viewItem == contextWorkspaceRoot)",
856-
"group": "1_modification@4"
856+
"group": "1_modification@1"
857857
},
858858
{
859859
"command": "codeWebChat.searchSelectedFilesFromDirectory",
860860
"when": "view == codeWebChatViewSelectedFiles && (viewItem == directory || viewItem == workspaceRoot || viewItem == contextDirectory || viewItem == contextWorkspaceRoot)",
861-
"group": "1_modification@4"
861+
"group": "1_modification@1"
862862
},
863863
{
864864
"command": "codeWebChat.selectParentFolder",
865865
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == file || viewItem == contextFile)",
866-
"group": "1_modification@5"
866+
"group": "1_modification@2"
867867
},
868868
{
869869
"command": "codeWebChat.selectReferencingFiles",
870870
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == file || viewItem == contextFile || viewItem == directory || viewItem == contextDirectory || viewItem == workspaceRoot || viewItem == contextWorkspaceRoot)",
871-
"group": "1_modification@6"
871+
"group": "1_modification@3"
872872
},
873873
{
874874
"command": "codeWebChat.selectImportedFiles",
875875
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == file || viewItem == contextFile || viewItem == directory || viewItem == contextDirectory || viewItem == workspaceRoot || viewItem == contextWorkspaceRoot)",
876-
"group": "1_modification@7"
876+
"group": "1_modification@4"
877877
},
878878
{
879879
"command": "codeWebChat.setRanges",

‎apps/editor/src/constants/state-keys.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ export const LAST_SEARCH_FILES_AGENT_QUERY_STATE_KEY =
8181

8282
export const LAST_SEARCH_FILES_FOR_CONTEXT_MODE_STATE_KEY =
8383
'last-search-files-for-context-mode'
84+
export const LAST_SEARCH_SELECTED_FILES_FOR_CONTEXT_MODE_STATE_KEY =
85+
'last-search-selected-files-for-context-mode'
8486

8587
export const LAST_SELECTED_WORKSPACE_IN_AGENT_SEARCH_STATE_KEY =
8688
'last-selected-workspace-in-agent-search'

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import * as vscode from 'vscode'
22
import { WorkspaceProvider } from '@/context/providers/workspace/workspace-provider'
33
import { t } from '@/i18n'
4-
import { LAST_SEARCH_FILES_FOR_CONTEXT_MODE_STATE_KEY } from '@/constants/state-keys'
4+
import {
5+
LAST_SEARCH_FILES_FOR_CONTEXT_MODE_STATE_KEY,
6+
LAST_SEARCH_SELECTED_FILES_FOR_CONTEXT_MODE_STATE_KEY
7+
} from '@/constants/state-keys'
58
import { prompt_for_search_mode } from './utils/prompt-for-search-mode'
69
import { perform_phrase_search_mode } from './search-modes/perform-phrase-search-mode'
710
import { perform_keywords_search_mode } from './search-modes/perform-keywords-search-mode'
@@ -25,10 +28,14 @@ export const search_files = async (params: {
2528
| undefined
2629
| 'back'
2730
> => {
31+
const mode_state_key = params.is_search_in_selected
32+
? LAST_SEARCH_SELECTED_FILES_FOR_CONTEXT_MODE_STATE_KEY
33+
: LAST_SEARCH_FILES_FOR_CONTEXT_MODE_STATE_KEY
34+
2835
let initial_search_mode =
2936
params.extension_context.workspaceState.get<
3037
'phrase' | 'keywords' | 'intelligent' | 'agent'
31-
>(LAST_SEARCH_FILES_FOR_CONTEXT_MODE_STATE_KEY) || 'phrase'
38+
>(mode_state_key) || 'phrase'
3239

3340
let _resolved_files: string[] | undefined
3441
const resolve_files = async () => {
@@ -66,7 +73,7 @@ export const search_files = async (params: {
6673
const search_mode = mode_result
6774

6875
await params.extension_context.workspaceState.update(
69-
LAST_SEARCH_FILES_FOR_CONTEXT_MODE_STATE_KEY,
76+
mode_state_key,
7077
search_mode
7178
)
7279

0 commit comments

Comments
 (0)