Skip to content

Commit 0eb40a9

Browse files
committed
Refactor select referencing files logic and update command menu groupings
- move 'search files...' up, right below 'reference in prompt' - it's been reported 'select referencing files' is not available on files but only on folders - in 'open editors', 'reveal in explorer view' should be in a separate section at the bottom
1 parent 7922080 commit 0eb40a9

2 files changed

Lines changed: 18 additions & 21 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -737,23 +737,28 @@
737737
{
738738
"command": "codeWebChat.referenceInPrompt",
739739
"when": "view == codeWebChatViewOpenEditors && viewItem == openEditor",
740-
"group": "2_modification@1"
740+
"group": "1_prompt@1"
741741
},
742742
{
743743
"command": "codeWebChat.selectImportedFiles",
744744
"when": "view == codeWebChatViewOpenEditors && viewItem == openEditor",
745745
"group": "2_modification@2"
746746
},
747747
{
748-
"command": "codeWebChat.setRanges",
748+
"command": "codeWebChat.selectReferencingFiles",
749749
"when": "view == codeWebChatViewOpenEditors && viewItem == openEditor",
750750
"group": "2_modification@3"
751751
},
752752
{
753-
"command": "codeWebChat.revealInExplorer",
753+
"command": "codeWebChat.setRanges",
754754
"when": "view == codeWebChatViewOpenEditors && viewItem == openEditor",
755755
"group": "2_modification@4"
756756
},
757+
{
758+
"command": "codeWebChat.revealInExplorer",
759+
"when": "view == codeWebChatViewOpenEditors && viewItem == openEditor",
760+
"group": "3_external@1"
761+
},
757762
{
758763
"command": "codeWebChat.newFile",
759764
"when": "view == codeWebChatViewWorkspace && (viewItem == directory || viewItem == workspaceRoot)",
@@ -777,21 +782,21 @@
777782
{
778783
"command": "codeWebChat.referenceInPrompt",
779784
"when": "view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles",
780-
"group": "1_modification@3"
785+
"group": "1_insertion@1"
781786
},
782787
{
783-
"command": "codeWebChat.selectImportedFiles",
784-
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == file || viewItem == contextFile || viewItem == directory || viewItem == contextDirectory || viewItem == workspaceRoot || viewItem == contextWorkspaceRoot)",
788+
"command": "codeWebChat.searchFilesFromDirectory",
789+
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == directory || viewItem == workspaceRoot || viewItem == contextDirectory || viewItem == contextWorkspaceRoot)",
785790
"group": "1_modification@4"
786791
},
787792
{
788-
"command": "codeWebChat.selectReferencingFiles",
789-
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == directory || viewItem == contextDirectory || viewItem == workspaceRoot || viewItem == contextWorkspaceRoot)",
793+
"command": "codeWebChat.selectImportedFiles",
794+
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == file || viewItem == contextFile || viewItem == directory || viewItem == contextDirectory || viewItem == workspaceRoot || viewItem == contextWorkspaceRoot)",
790795
"group": "1_modification@5"
791796
},
792797
{
793-
"command": "codeWebChat.searchFilesFromDirectory",
794-
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == directory || viewItem == workspaceRoot || viewItem == contextDirectory || viewItem == contextWorkspaceRoot)",
798+
"command": "codeWebChat.selectReferencingFiles",
799+
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == file || viewItem == contextFile || viewItem == directory || viewItem == contextDirectory || viewItem == workspaceRoot || viewItem == contextWorkspaceRoot)",
795800
"group": "1_modification@6"
796801
},
797802
{

‎apps/editor/src/commands/select-referencing-files-command.ts‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,12 @@ export const select_referencing_files_command = (
1616
'codeWebChat.selectReferencingFiles',
1717
async (item?: FileItem) => {
1818
try {
19-
let is_folder = false
20-
if (item && item.resourceUri) {
21-
try {
22-
const stat = await vscode.workspace.fs.stat(item.resourceUri)
23-
is_folder = (stat.type & vscode.FileType.Directory) !== 0
24-
} catch {}
25-
}
26-
2719
let matched_files: { file_path: string; range: vscode.Range }[] = []
2820

29-
if (is_folder && item?.resourceUri) {
30-
const folder_uri = item.resourceUri
21+
if (item?.resourceUri) {
22+
const target_uri = item.resourceUri
3123
const starting_uris = await get_all_files(
32-
folder_uri,
24+
target_uri,
3325
workspace_provider
3426
)
3527

0 commit comments

Comments
 (0)