Skip to content

Commit bcf2c42

Browse files
committed
Expand select imported files command to support uri and active editor targets
- always place 'select referencing files' above 'select imported files' - add support for 'select imported files' from the file context menu as well - add missing translations [Pasted text]
1 parent 690af31 commit bcf2c42

3 files changed

Lines changed: 67 additions & 50 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,6 @@
283283
"title": "%codeWebChat.delete.title%",
284284
"icon": "$(trash)"
285285
},
286-
{
287-
"command": "codeWebChat.selectImportedFiles",
288-
"title": "%codeWebChat.selectImportedFiles.title%"
289-
},
290286
{
291287
"command": "codeWebChat.referenceInPrompt",
292288
"title": "%codeWebChat.referenceInPrompt.title%",
@@ -363,6 +359,11 @@
363359
"title": "%codeWebChat.selectReferencingFiles.title%",
364360
"category": "Code Web Chat"
365361
},
362+
{
363+
"command": "codeWebChat.selectImportedFiles",
364+
"title": "%codeWebChat.selectImportedFiles.title%",
365+
"category": "Code Web Chat"
366+
},
366367
{
367368
"command": "codeWebChat.selectReferencingFilesForSelected",
368369
"title": "%codeWebChat.selectReferencingFilesForSelected.title%",
@@ -456,8 +457,12 @@
456457
"group": "1_action@5"
457458
},
458459
{
459-
"command": "codeWebChat.selectDefinitionFile",
460+
"command": "codeWebChat.selectImportedFiles",
460461
"group": "1_action@6"
462+
},
463+
{
464+
"command": "codeWebChat.selectDefinitionFile",
465+
"group": "1_action@7"
461466
}
462467
],
463468
"commandPalette": [
@@ -819,12 +824,12 @@
819824
"group": "2_modification@2"
820825
},
821826
{
822-
"command": "codeWebChat.selectImportedFiles",
827+
"command": "codeWebChat.selectReferencingFiles",
823828
"when": "view == codeWebChatViewOpenEditors && viewItem == openEditor",
824829
"group": "2_modification@3"
825830
},
826831
{
827-
"command": "codeWebChat.selectReferencingFiles",
832+
"command": "codeWebChat.selectImportedFiles",
828833
"when": "view == codeWebChatViewOpenEditors && viewItem == openEditor",
829834
"group": "2_modification@4"
830835
},
@@ -874,12 +879,12 @@
874879
"group": "1_modification@5"
875880
},
876881
{
877-
"command": "codeWebChat.selectImportedFiles",
882+
"command": "codeWebChat.selectReferencingFiles",
878883
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == file || viewItem == contextFile || viewItem == directory || viewItem == contextDirectory || viewItem == workspaceRoot || viewItem == contextWorkspaceRoot)",
879884
"group": "1_modification@6"
880885
},
881886
{
882-
"command": "codeWebChat.selectReferencingFiles",
887+
"command": "codeWebChat.selectImportedFiles",
883888
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == file || viewItem == contextFile || viewItem == directory || viewItem == contextDirectory || viewItem == workspaceRoot || viewItem == contextWorkspaceRoot)",
884889
"group": "1_modification@7"
885890
},

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import * as vscode from 'vscode'
2-
import {
3-
WorkspaceProvider,
4-
FileItem
5-
} from '../context/providers/workspace/workspace-provider'
2+
import { WorkspaceProvider } from '../context/providers/workspace/workspace-provider'
63
import { prompt_for_imported_files } from '@/features/imported-files'
74
import { t } from '@/i18n'
85

@@ -12,12 +9,27 @@ export const select_imported_files_command = (
129
) => {
1310
return vscode.commands.registerCommand(
1411
'codeWebChat.selectImportedFiles',
15-
async (item: FileItem) => {
16-
if (!item) return
12+
async (item?: any) => {
13+
let target_uri: vscode.Uri | undefined
1714

18-
const starting_uris = await workspace_provider.get_all_files_for_uri(
19-
item.resourceUri
20-
)
15+
if (item?.resourceUri) {
16+
target_uri = item.resourceUri
17+
} else if (
18+
item instanceof vscode.Uri ||
19+
(item && item.fsPath && item.scheme)
20+
) {
21+
target_uri = item as vscode.Uri
22+
} else {
23+
const editor = vscode.window.activeTextEditor
24+
if (editor) {
25+
target_uri = editor.document.uri
26+
}
27+
}
28+
29+
if (!target_uri) return
30+
31+
const starting_uris =
32+
await workspace_provider.get_all_files_for_uri(target_uri)
2133

2234
if (starting_uris.length == 0) {
2335
vscode.window.showInformationMessage(

‎apps/editor/src/i18n/translations/features/imported-files.ts‎

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -54,40 +54,40 @@ export const translations = {
5454
bg: 'Дълбоко търсене на импортирания'
5555
},
5656
'feature.imported-files.immediate': {
57-
en: 'Immediate Imports',
58-
pl: 'Bezpośrednie importy',
59-
'zh-cn': '直接导入',
60-
ja: '直接のインポート',
61-
'zh-tw': '直接匯入',
62-
de: 'Direkte Importe',
63-
es: 'Importaciones inmediatas',
64-
fr: 'Importations immédiates',
65-
'pt-br': 'Importações imediatas',
66-
ru: 'Прямые импорты',
67-
ko: '직접 가져오기',
68-
it: 'Importazioni immediate',
69-
tr: 'Doğrudan İçe Aktarmalar',
70-
cs: 'Okamžité importy',
71-
hu: 'Közvetlen importálások',
72-
bg: 'Незабавни импортирания'
57+
en: 'immediate',
58+
pl: 'bezpośrednie',
59+
'zh-cn': '直接',
60+
ja: '直接',
61+
'zh-tw': '直接',
62+
de: 'direkt',
63+
es: 'directo',
64+
fr: 'direct',
65+
'pt-br': 'direto',
66+
ru: 'прямые',
67+
ko: '직접',
68+
it: 'diretto',
69+
tr: 'doğrudan',
70+
cs: 'přímé',
71+
hu: 'közvetlen',
72+
bg: 'преки'
7373
},
7474
'feature.imported-files.recursive': {
75-
en: 'Recursive Imports',
76-
pl: 'Rekurencyjne importy',
77-
'zh-cn': '递归导入',
78-
ja: '再帰的なインポート',
79-
'zh-tw': '遞迴匯入',
80-
de: 'Rekursive Importe',
81-
es: 'Importaciones recursivas',
82-
fr: 'Importations récursives',
83-
'pt-br': 'Importações recursivas',
84-
ru: 'Рекурсивные импорты',
85-
ko: '재귀적 가져오기',
86-
it: 'Importazioni ricorsive',
87-
tr: 'Yinelemeli İçe Aktarmalar',
88-
cs: 'Rekurzivní importy',
89-
hu: 'Rekurzív importálások',
90-
bg: 'Рекурсивни импортирания'
75+
en: 'recursive',
76+
pl: 'rekurencyjne',
77+
'zh-cn': '递归',
78+
ja: '再帰的',
79+
'zh-tw': '遞迴',
80+
de: 'rekursiv',
81+
es: 'recursivo',
82+
fr: 'récursif',
83+
'pt-br': 'recursivo',
84+
ru: 'рекурсивные',
85+
ko: '재귀적',
86+
it: 'ricorsivo',
87+
tr: 'yinelemeli',
88+
cs: 'rekurzivní',
89+
hu: 'rekurzív',
90+
bg: 'рекурсивни'
9191
},
9292
'feature.imported-files.placeholder-tokens': {
9393
en: 'Select imported files ({tokens})',

0 commit comments

Comments
 (0)