Skip to content

Commit 9169aa7

Browse files
committed
Add progress reporting to select imported files command and update referencing files translation keys
- the progress on 'select imported files' should reflect the actual progress
1 parent 6ab64e4 commit 9169aa7

2 files changed

Lines changed: 55 additions & 17 deletions

File tree

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,27 @@ export const select_imported_files_command = (
4747
},
4848
async (progress, token) => {
4949
const queue: vscode.Uri[] = []
50+
let processed = 0
51+
let total = starting_uris.length
52+
let last_reported_percentage = 0
5053

5154
for (const starting_uri of starting_uris) {
5255
if (token.isCancellationRequested) {
5356
is_cancelled = true
5457
break
5558
}
59+
60+
const current_percentage = Math.floor((processed / total) * 100)
61+
const increment = Math.max(
62+
0,
63+
current_percentage - last_reported_percentage
64+
)
65+
last_reported_percentage += increment
66+
67+
progress.report({
68+
increment
69+
})
70+
5671
const imports = await get_imports_for_uri(starting_uri, token)
5772
for (const uri_str of imports) {
5873
if (!visited_uris.has(uri_str)) {
@@ -63,24 +78,47 @@ export const select_imported_files_command = (
6378
}
6479
}
6580
}
81+
processed++
6682
}
6783

84+
total += queue.length
85+
6886
while (queue.length > 0) {
6987
if (token.isCancellationRequested) {
7088
is_cancelled = true
7189
break
7290
}
7391
const current_uri = queue.shift()!
92+
93+
const current_percentage = Math.floor((processed / total) * 100)
94+
const increment = Math.max(
95+
0,
96+
current_percentage - last_reported_percentage
97+
)
98+
last_reported_percentage += increment
99+
100+
progress.report({
101+
increment
102+
})
103+
74104
const imports = await get_imports_for_uri(current_uri, token)
75105
for (const uri_str of imports) {
76106
if (!visited_uris.has(uri_str)) {
77107
visited_uris.add(uri_str)
78108
if (is_valid_uri(uri_str, workspace_provider)) {
79109
recursive_uris.add(uri_str)
80110
queue.push(vscode.Uri.parse(uri_str))
111+
total++
81112
}
82113
}
83114
}
115+
processed++
116+
}
117+
118+
if (!is_cancelled) {
119+
progress.report({
120+
increment: 100 - last_reported_percentage
121+
})
84122
}
85123
}
86124
)

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
export const translations = {
2-
'command.select-referencing-files.searching': {
3-
en: 'Searching for references...',
4-
pl: 'Wyszukiwanie odwołań...',
5-
'zh-cn': '正在搜索引用...',
6-
ja: '参照を検索中...',
7-
'zh-tw': '正在搜尋參考...',
8-
de: 'Suche nach Referenzen...',
9-
es: 'Buscando referencias...',
10-
fr: 'Recherche de références...',
11-
'pt-br': 'Procurando por referências...',
12-
ru: 'Поиск ссылок...',
13-
ko: '참조 검색 중...',
14-
it: 'Ricerca di riferimenti in corso...',
15-
tr: 'Referanslar aranıyor...',
16-
cs: 'Hledání referencí...',
17-
hu: 'Hivatkozások keresése...',
18-
bg: 'Търсене на референции...'
2+
'command.select-referencing-files.processing': {
3+
en: 'Processing references...',
4+
pl: 'Przetwarzanie odwołań...',
5+
'zh-cn': '正在处理引用...',
6+
ja: '参照を処理中...',
7+
'zh-tw': '正在處理參考...',
8+
de: 'Referenzen werden verarbeitet...',
9+
es: 'Procesando referencias...',
10+
fr: 'Traitement des références...',
11+
'pt-br': 'Processando referências...',
12+
ru: 'Обработка ссылок...',
13+
ko: '참조 처리 중...',
14+
it: 'Elaborazione dei riferimenti...',
15+
tr: 'Referanslar işleniyor...',
16+
cs: 'Zpracování referencí...',
17+
hu: 'Hivatkozások feldolgozása...',
18+
bg: 'Обработка на референциите...'
1919
},
2020
'command.select-referencing-files.no-files': {
2121
en: 'No references found.',

0 commit comments

Comments
 (0)