Skip to content

Commit aa8092a

Browse files
committedJul 12, 2024
fix: setting menu go back route error
1 parent a9f9aeb commit aa8092a

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed
 

‎src/view/quickInput/clearTranslationCachePopconfirm.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export function showClearTranslationCachePopconfirm(ctx: Context) {
1010
quickPick.title = 'Are you sure to clear translation cache?'
1111
quickPick.matchOnDescription = true
1212
quickPick.matchOnDetail = true
13+
let routeJumping = false
14+
quickPick.onDidChangeSelection(() => routeJumping = true)
1315
defineQuickPickItems(quickPick, [
1416
{
1517
label: '$(x) No',
@@ -28,12 +30,12 @@ export function showClearTranslationCachePopconfirm(ctx: Context) {
2830
]
2931
quickPick.onDidTriggerButton((button) => {
3032
if (button === QuickInputButtons.Back)
31-
showSettingsPopmenu(ctx)
33+
quickPick.hide()
3234
})
3335

3436
quickPick.onDidHide(() => {
35-
quickPick.dispose()
36-
showSettingsPopmenu(ctx)
37+
if (!routeJumping)
38+
showSettingsPopmenu(ctx)
3739
})
3840
quickPick.show()
3941
}

‎src/view/quickInput/setKnownPopularWordInput.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export function showSetKnownPopularWordInput(ctx: Context) {
88
const inputBox = window.createInputBox()
99
inputBox.title = 'Known Popular Words'
1010
inputBox.value = String(config.knownPopularWordCount || 0)
11+
let routeJumping = false
1112

1213
inputBox.onDidAccept(() => {
1314
const count = Number(inputBox.value)
@@ -16,6 +17,7 @@ export function showSetKnownPopularWordInput(ctx: Context) {
1617
return
1718
}
1819
config.knownPopularWordCount = count
20+
routeJumping = true
1921
showTranslatePopmenu(ctx)
2022
})
2123

@@ -24,12 +26,12 @@ export function showSetKnownPopularWordInput(ctx: Context) {
2426
]
2527
inputBox.onDidTriggerButton((button) => {
2628
if (button === QuickInputButtons.Back)
27-
showTranslatePopmenu(ctx)
29+
inputBox.hide()
2830
})
2931

3032
inputBox.onDidHide(() => {
31-
inputBox.dispose()
32-
showSettingsPopmenu(ctx)
33+
if (!routeJumping)
34+
showSettingsPopmenu(ctx)
3335
})
3436
inputBox.show()
3537
}

‎src/view/quickInput/settingsPopmenu.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ export function showSettingsPopmenu(ctx: Context) {
3535
quickPick.buttons = [QuickInputButtons.Back]
3636
quickPick.onDidTriggerButton((button) => {
3737
if (button === QuickInputButtons.Back)
38-
showTranslatePopmenu(ctx)
38+
quickPick.hide()
3939
})
4040

4141
quickPick.onDidHide(() => {
42-
quickPick.dispose()
4342
if (!routeJumping)
4443
showTranslatePopmenu(ctx)
4544
})

0 commit comments

Comments
 (0)