Skip to content

Commit e4d6a7e

Browse files
committed
Refactor and split context restoration translation keys into dedicated command and feature files
- change: "[files] · [tokens]" to "[tokens] ([files])" - fix translations so that those used in features live in features folder, also properly rename `apps/editor/src/i18n/translations/commands/context-restoration.ts` to appropriate command names and fix keys └── apps └── editor └── src ├── commands │ ├── generate-commit-message-command │ │ ├── actions │ │ │ ├── get-prompt-data.ts │ │ │ └── run-generate-action.ts │ │ ├── generate-commit-message-command.ts │ │ └── index.ts │ ├── index.ts │ ├── restore-file-selection-command │ │ ├── actions │ │ │ ├── restore-from-json-file.ts │ │ │ └── restore-from-workspace-state.ts │ │ ├── index.ts │ │ └── restore-file-selection-command.ts │ └── save-file-selection-command │ ├── actions │ │ ├── save-to-json-file.ts │ │ └── save-to-workspace-state.ts │ ├── index.ts │ └── save-file-selection-command.ts ├── features │ ├── commit-messages │ │ ├── index.ts │ │ └── utils │ │ ├── build-commit-message-prompt.ts │ │ ├── generate-commit-message-with-api.ts │ │ ├── get-commit-message-config.ts │ │ └── strip-wrapping-quotes.ts │ └── context-restoration │ ├── index.ts │ └── utils │ ├── ask-for-new-context-name.ts │ ├── context-file-utils.ts │ ├── create-context-description.ts │ ├── file-contexts.ts │ ├── global-storage-utils.ts │ ├── path-utils.ts │ ├── resolve-context-paths.ts │ ├── resolve-glob-patterns.ts │ ├── resolve-paths.ts │ ├── select-context-paths.ts │ └── source-selector.ts ├── i18n │ ├── index.ts │ └── translations │ ├── commands │ │ ├── context-restoration.ts │ │ ├── generate-commit-message.ts │ │ ├── index.ts │ │ ├── restore-file-selection.ts │ │ └── save-file-selection.ts │ └── features │ ├── checkpoints.ts │ ├── context-restoration.ts │ ├── imported-files.ts │ ├── index.ts │ ├── referencing-files.ts │ └── search-files.ts └── views └── prompt └── backend ├── message-handlers │ └── handle-hash-sign-quick-pick │ └── symbols │ └── saved-context-symbol.ts └── utils └── symbols └── saved-context └── replace-saved-context-symbol.ts
1 parent cb8e571 commit e4d6a7e

15 files changed

Lines changed: 625 additions & 351 deletions

File tree

‎apps/editor/src/commands/restore-file-selection-command/actions/restore-from-json-file.ts‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ export const restore_from_json_file = async (params: {
2929

3030
const edit_button = {
3131
iconPath: new vscode.ThemeIcon('edit'),
32-
tooltip: t('command.context-restoration.action.rename')
32+
tooltip: t('command.restore-file-selection.action.rename')
3333
}
3434
const delete_button = {
3535
iconPath: new vscode.ThemeIcon('trash'),
36-
tooltip: t('command.context-restoration.action.delete')
36+
tooltip: t('command.restore-file-selection.action.delete')
3737
}
3838

3939
let active_dialog_count = 0
@@ -48,7 +48,7 @@ export const restore_from_json_file = async (params: {
4848

4949
if (file_contexts.length > 0) {
5050
items.push({
51-
label: t('command.context-restoration.entries-az'),
51+
label: t('command.restore-file-selection.entries-az'),
5252
kind: vscode.QuickPickItemKind.Separator
5353
})
5454

@@ -77,9 +77,9 @@ export const restore_from_json_file = async (params: {
7777
: { iconPath: new vscode.ThemeIcon('close'), tooltip: 'Close' }
7878

7979
const quick_pick = vscode.window.createQuickPick<any>()
80-
quick_pick.title = t('command.context-restoration.select-saved.title')
80+
quick_pick.title = t('command.restore-file-selection.select-saved.title')
8181
quick_pick.placeholder = t(
82-
'command.context-restoration.select-saved.file'
82+
'command.restore-file-selection.select-saved.file'
8383
)
8484
quick_pick.buttons = [back_or_close_button]
8585
quick_pick.items = await create_items()
@@ -136,8 +136,8 @@ export const restore_from_json_file = async (params: {
136136
if (selection.triggeredButton === edit_button) {
137137
active_dialog_count++
138138
const input_box = vscode.window.createInputBox()
139-
input_box.title = t('command.context-restoration.rename.title')
140-
input_box.prompt = t('command.context-restoration.rename.prompt')
139+
input_box.title = t('command.restore-file-selection.rename.title')
140+
input_box.prompt = t('command.restore-file-selection.rename.prompt')
141141
input_box.value = old_name
142142
const new_name = await new Promise<string | undefined>((resolve) => {
143143
let accepted = false
@@ -146,7 +146,7 @@ export const restore_from_json_file = async (params: {
146146
const trimmed = value.trim()
147147
if (!trimmed) {
148148
input_box.validationMessage = t(
149-
'command.context-restoration.rename.empty'
149+
'command.restore-file-selection.rename.empty'
150150
)
151151
return false
152152
}
@@ -156,7 +156,7 @@ export const restore_from_json_file = async (params: {
156156
)
157157
) {
158158
input_box.validationMessage = t(
159-
'command.context-restoration.rename.exists'
159+
'command.restore-file-selection.rename.exists'
160160
)
161161
return false
162162
}
@@ -206,13 +206,15 @@ export const restore_from_json_file = async (params: {
206206
} else if (selection.triggeredButton === delete_button) {
207207
active_dialog_count++
208208
const choice = await vscode.window.showInformationMessage(
209-
t('command.context-restoration.delete.prompt', { name: old_name }),
209+
t('command.restore-file-selection.delete.prompt', {
210+
name: old_name
211+
}),
210212
{ modal: true },
211-
t('command.context-restoration.delete.action')
213+
t('command.restore-file-selection.delete.action')
212214
)
213215
active_dialog_count--
214216

215-
if (choice == t('command.context-restoration.delete.action')) {
217+
if (choice == t('command.restore-file-selection.delete.action')) {
216218
const roots_to_update = context_to_roots.get(old_name) || []
217219
for (const root of roots_to_update) {
218220
const p = get_contexts_file_path(root)

‎apps/editor/src/commands/restore-file-selection-command/actions/restore-from-workspace-state.ts‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ export const restore_from_workspace_state = async (params: {
2929

3030
const edit_button = {
3131
iconPath: new vscode.ThemeIcon('edit'),
32-
tooltip: t('command.context-restoration.action.rename')
32+
tooltip: t('command.restore-file-selection.action.rename')
3333
}
3434
const delete_button = {
3535
iconPath: new vscode.ThemeIcon('trash'),
36-
tooltip: t('command.context-restoration.action.delete')
36+
tooltip: t('command.restore-file-selection.action.delete')
3737
}
3838

3939
while (true) {
@@ -46,7 +46,7 @@ export const restore_from_workspace_state = async (params: {
4646

4747
if (contexts.length > 0) {
4848
items.push({
49-
label: t('command.context-restoration.recent-entries'),
49+
label: t('command.restore-file-selection.recent-entries'),
5050
kind: vscode.QuickPickItemKind.Separator
5151
})
5252

@@ -78,9 +78,9 @@ export const restore_from_workspace_state = async (params: {
7878
: { iconPath: new vscode.ThemeIcon('close'), tooltip: 'Close' }
7979

8080
const quick_pick = vscode.window.createQuickPick()
81-
quick_pick.title = t('command.context-restoration.select-saved.title')
81+
quick_pick.title = t('command.restore-file-selection.select-saved.title')
8282
quick_pick.placeholder = t(
83-
'command.context-restoration.select-saved.workspace'
83+
'command.restore-file-selection.select-saved.workspace'
8484
)
8585
quick_pick.buttons = [back_or_close_button]
8686
quick_pick.items = await create_quick_pick_items(internal_contexts)
@@ -124,8 +124,10 @@ export const restore_from_workspace_state = async (params: {
124124
if (event.button === edit_button) {
125125
active_dialog_count++
126126
const input_box = vscode.window.createInputBox()
127-
input_box.title = t('command.context-restoration.rename.title')
128-
input_box.prompt = t('command.context-restoration.rename.prompt')
127+
input_box.title = t('command.restore-file-selection.rename.title')
128+
input_box.prompt = t(
129+
'command.restore-file-selection.rename.prompt'
130+
)
129131
input_box.value = item.context.name
130132

131133
const new_name = await new Promise<string | undefined | 'back'>(
@@ -136,7 +138,7 @@ export const restore_from_workspace_state = async (params: {
136138
const trimmed = value.trim()
137139
if (!trimmed) {
138140
input_box.validationMessage = t(
139-
'command.context-restoration.rename.empty'
141+
'command.restore-file-selection.rename.empty'
140142
)
141143
return false
142144
}
@@ -147,7 +149,7 @@ export const restore_from_workspace_state = async (params: {
147149
)
148150
) {
149151
input_box.validationMessage = t(
150-
'command.context-restoration.rename.exists'
152+
'command.restore-file-selection.rename.exists'
151153
)
152154
return false
153155
}
@@ -257,7 +259,7 @@ export const restore_from_workspace_state = async (params: {
257259
if (active_deletion_timestamp !== current_timestamp) {
258260
if (choice == 'Undo')
259261
vscode.window.showInformationMessage(
260-
t('command.context-restoration.undo.failed')
262+
t('command.restore-file-selection.undo.failed')
261263
)
262264
quick_pick.show()
263265
return

‎apps/editor/src/commands/restore-file-selection-command/restore-file-selection-command.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const restore_file_selection_command = (params: {
2020

2121
const { source, skipped_menu } = await select_context_source({
2222
extension_context: params.extension_context,
23-
title: t('command.context-restoration.source.title'),
23+
title: t('command.restore-file-selection.source.title'),
2424
mode: 'restore'
2525
})
2626

‎apps/editor/src/commands/save-file-selection-command/actions/save-to-json-file.ts‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ export const save_to_json_file = async (params: {
2424
let { merged: file_contexts, context_to_roots } =
2525
await load_and_merge_file_contexts()
2626
const LABEL_SAVE_NEW_CONTEXT = t(
27-
'command.context-restoration.save-new-context.label'
27+
'command.save-file-selection.save-new-context.label'
2828
)
2929

3030
const edit_button = {
3131
iconPath: new vscode.ThemeIcon('edit'),
32-
tooltip: t('command.context-restoration.action.rename')
32+
tooltip: t('command.save-file-selection.action.rename')
3333
}
3434
const delete_button = {
3535
iconPath: new vscode.ThemeIcon('trash'),
36-
tooltip: t('command.context-restoration.action.delete')
36+
tooltip: t('command.save-file-selection.action.delete')
3737
}
3838

3939
let name_to_highlight: string | undefined
@@ -44,7 +44,7 @@ export const save_to_json_file = async (params: {
4444

4545
if (file_contexts.length > 0) {
4646
items.push({
47-
label: t('command.context-restoration.entries-az'),
47+
label: t('command.save-file-selection.entries-az'),
4848
kind: vscode.QuickPickItemKind.Separator
4949
})
5050
for (const context of file_contexts) {
@@ -65,8 +65,8 @@ export const save_to_json_file = async (params: {
6565
}
6666

6767
const quick_pick = vscode.window.createQuickPick<any>()
68-
quick_pick.title = t('command.context-restoration.select-saved.title')
69-
quick_pick.placeholder = t('command.context-restoration.save.placeholder')
68+
quick_pick.title = t('command.save-file-selection.select-saved.title')
69+
quick_pick.placeholder = t('command.save-file-selection.save.placeholder')
7070
quick_pick.items = items
7171
quick_pick.buttons = [vscode.QuickInputButtons.Back]
7272

@@ -116,8 +116,8 @@ export const save_to_json_file = async (params: {
116116

117117
if (selection.triggeredButton === edit_button) {
118118
const input_box = vscode.window.createInputBox()
119-
input_box.title = t('command.context-restoration.rename.title')
120-
input_box.prompt = t('command.context-restoration.rename.prompt')
119+
input_box.title = t('command.save-file-selection.rename.title')
120+
input_box.prompt = t('command.save-file-selection.rename.prompt')
121121
input_box.value = old_name
122122
const new_name = await new Promise<string | undefined>((resolve) => {
123123
let accepted = false
@@ -126,7 +126,7 @@ export const save_to_json_file = async (params: {
126126
const trimmed = value.trim()
127127
if (!trimmed) {
128128
input_box.validationMessage = t(
129-
'command.context-restoration.rename.empty'
129+
'command.save-file-selection.rename.empty'
130130
)
131131
return false
132132
}
@@ -136,7 +136,7 @@ export const save_to_json_file = async (params: {
136136
)
137137
) {
138138
input_box.validationMessage = t(
139-
'command.context-restoration.rename.exists'
139+
'command.save-file-selection.rename.exists'
140140
)
141141
return false
142142
}
@@ -183,12 +183,12 @@ export const save_to_json_file = async (params: {
183183
new_name && new_name != old_name ? new_name : old_name
184184
} else if (selection.triggeredButton === delete_button) {
185185
const choice = await vscode.window.showInformationMessage(
186-
t('command.context-restoration.delete.prompt', { name: old_name }),
186+
t('command.save-file-selection.delete.prompt', { name: old_name }),
187187
{ modal: true },
188-
t('command.context-restoration.delete.action')
188+
t('command.save-file-selection.delete.action')
189189
)
190190

191-
if (choice == t('command.context-restoration.delete.action')) {
191+
if (choice == t('command.save-file-selection.delete.action')) {
192192
const roots_to_update = context_to_roots.get(old_name) || []
193193
for (const root of roots_to_update) {
194194
const p = get_contexts_file_path(root)
@@ -257,14 +257,14 @@ export const save_to_json_file = async (params: {
257257
if (selection.context) {
258258
const context_name = selection.context.name
259259
const choice = await vscode.window.showWarningMessage(
260-
t('command.context-restoration.overwrite.prompt', {
260+
t('command.save-file-selection.overwrite.prompt', {
261261
name: context_name
262262
}),
263263
{ modal: true },
264-
t('command.context-restoration.overwrite.action')
264+
t('command.save-file-selection.overwrite.action')
265265
)
266266

267-
if (choice === t('command.context-restoration.overwrite.action')) {
267+
if (choice === t('command.save-file-selection.overwrite.action')) {
268268
const current_roots = context_to_roots.get(context_name) || []
269269
const all_roots = new Set([
270270
...current_roots,

‎apps/editor/src/commands/save-file-selection-command/actions/save-to-workspace-state.ts‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ export const save_to_workspace_state = async (params: {
2020
let { merged: internal_contexts, context_to_roots } =
2121
load_and_merge_global_contexts(params.extension_context)
2222
const LABEL_SAVE_NEW_CONTEXT = t(
23-
'command.context-restoration.save-new-context.label'
23+
'command.save-file-selection.save-new-context.label'
2424
)
2525

2626
const edit_button = {
2727
iconPath: new vscode.ThemeIcon('edit'),
28-
tooltip: t('command.context-restoration.action.rename')
28+
tooltip: t('command.save-file-selection.action.rename')
2929
}
3030
const delete_button = {
3131
iconPath: new vscode.ThemeIcon('trash'),
32-
tooltip: t('command.context-restoration.action.delete')
32+
tooltip: t('command.save-file-selection.action.delete')
3333
}
3434

3535
let name_to_highlight: string | undefined
@@ -40,7 +40,7 @@ export const save_to_workspace_state = async (params: {
4040

4141
if (internal_contexts.length > 0) {
4242
items.push({
43-
label: t('command.context-restoration.recent-entries'),
43+
label: t('command.save-file-selection.recent-entries'),
4444
kind: vscode.QuickPickItemKind.Separator
4545
})
4646
for (const context of internal_contexts) {
@@ -61,8 +61,8 @@ export const save_to_workspace_state = async (params: {
6161
}
6262

6363
const quick_pick = vscode.window.createQuickPick<any>()
64-
quick_pick.title = t('command.context-restoration.select-saved.title')
65-
quick_pick.placeholder = t('command.context-restoration.save.placeholder')
64+
quick_pick.title = t('command.save-file-selection.select-saved.title')
65+
quick_pick.placeholder = t('command.save-file-selection.save.placeholder')
6666
quick_pick.items = items
6767
quick_pick.buttons = [vscode.QuickInputButtons.Back]
6868

@@ -112,8 +112,8 @@ export const save_to_workspace_state = async (params: {
112112

113113
if (selection.triggeredButton === edit_button) {
114114
const input_box = vscode.window.createInputBox()
115-
input_box.title = t('command.context-restoration.rename.title')
116-
input_box.prompt = t('command.context-restoration.rename.prompt')
115+
input_box.title = t('command.save-file-selection.rename.title')
116+
input_box.prompt = t('command.save-file-selection.rename.prompt')
117117
input_box.value = old_name
118118
const new_name = await new Promise<string | undefined>((resolve) => {
119119
let accepted = false
@@ -122,7 +122,7 @@ export const save_to_workspace_state = async (params: {
122122
const trimmed = value.trim()
123123
if (!trimmed) {
124124
input_box.validationMessage = t(
125-
'command.context-restoration.rename.empty'
125+
'command.save-file-selection.rename.empty'
126126
)
127127
return false
128128
}
@@ -132,7 +132,7 @@ export const save_to_workspace_state = async (params: {
132132
)
133133
) {
134134
input_box.validationMessage = t(
135-
'command.context-restoration.rename.exists'
135+
'command.save-file-selection.rename.exists'
136136
)
137137
return false
138138
}
@@ -184,12 +184,12 @@ export const save_to_workspace_state = async (params: {
184184
new_name && new_name != old_name ? new_name : old_name
185185
} else if (selection.triggeredButton === delete_button) {
186186
const choice = await vscode.window.showInformationMessage(
187-
t('command.context-restoration.delete.prompt', { name: old_name }),
187+
t('command.save-file-selection.delete.prompt', { name: old_name }),
188188
{ modal: true },
189-
t('command.context-restoration.delete.action')
189+
t('command.save-file-selection.delete.action')
190190
)
191191

192-
if (choice == t('command.context-restoration.delete.action')) {
192+
if (choice == t('command.save-file-selection.delete.action')) {
193193
const roots = context_to_roots.get(old_name) || []
194194
for (const root of roots) {
195195
const root_contexts = load_contexts_for_workspace({
@@ -262,14 +262,14 @@ export const save_to_workspace_state = async (params: {
262262
if (selection.context) {
263263
const context_name = selection.context.name
264264
const choice = await vscode.window.showWarningMessage(
265-
t('command.context-restoration.overwrite.prompt', {
265+
t('command.save-file-selection.overwrite.prompt', {
266266
name: context_name
267267
}),
268268
{ modal: true },
269-
t('command.context-restoration.overwrite.action')
269+
t('command.save-file-selection.overwrite.action')
270270
)
271271

272-
if (choice === t('command.context-restoration.overwrite.action')) {
272+
if (choice === t('command.save-file-selection.overwrite.action')) {
273273
const current_roots = context_to_roots.get(context_name) || []
274274
const all_roots = new Set([
275275
...current_roots,

‎apps/editor/src/commands/save-file-selection-command/save-file-selection-command.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const save_file_selection_command = (params: {
2828

2929
const { source } = await select_context_source({
3030
extension_context: params.extension_context,
31-
title: t('command.context-restoration.destination.title'),
31+
title: t('command.save-file-selection.destination.title'),
3232
mode: 'save'
3333
})
3434

0 commit comments

Comments
 (0)