fix(editor): display configured execute shortcut
This commit is contained in:
1 parent
30d13bc7f0
commit
df95288aab
11 files changed
+80
-21
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import i18n, { setLocale } from "@/i18n";
|
||||
import { formatShortcutDisplay } from "@/lib/editor/shortcutDisplay";
|
||||
|
||||
// https://github.com/t8y2/dbx/issues/6199
|
||||
// "设置为 Windows 但编辑器提示仍为 Mac" — the toolbar's Execute-button tooltip and the
|
||||
// Editor Settings "Execute Mode" label hardcode "(Cmd+Enter)" in every locale, including
|
||||
// English, so the hints can disagree with both the current platform and a customized binding.
|
||||
|
||||
const toolbarSource = readFileSync(new URL("../../components/layout/EditorToolbar.vue", import.meta.url), "utf8");
|
||||
const settingsDialogSource = readFileSync(new URL("../../components/editor/EditorSettingsDialog.vue", import.meta.url), "utf8");
|
||||
|
||||
describe("execute-shortcut hints reflect the configured binding", () => {
|
||||
it.each([
|
||||
["MacIntel", "Mod+Enter", "⌘ ↵"],
|
||||
["Win32", "Mod+Enter", "Ctrl + ↵"],
|
||||
["Linux x86_64", "Mod+Enter", "Ctrl + ↵"],
|
||||
["Win32", "Shift+Mod+Enter", "Ctrl + Shift + ↵"],
|
||||
])("formats %s shortcuts for the active platform", (platform, shortcut, expected) => {
|
||||
expect(formatShortcutDisplay(shortcut, platform)).toBe(expected);
|
||||
});
|
||||
|
||||
it("interpolates the formatted shortcut into toolbar and settings labels", async () => {
|
||||
const shortcut = formatShortcutDisplay("Shift+Mod+Enter", "Win32");
|
||||
|
||||
await setLocale("en");
|
||||
expect(i18n.global.t("toolbar.executeShortcut", { shortcut })).toBe("Execute selection/query (Ctrl + Shift + ↵)");
|
||||
expect(i18n.global.t("settings.executeMode", { shortcut })).toBe("Execute Mode (Ctrl + Shift + ↵)");
|
||||
|
||||
await setLocale("zh-CN");
|
||||
expect(i18n.global.t("toolbar.executeShortcut", { shortcut })).toBe("执行选中/全部 (Ctrl + Shift + ↵)");
|
||||
expect(i18n.global.t("settings.executeMode", { shortcut })).toBe("执行模式 (Ctrl + Shift + ↵)");
|
||||
await setLocale("en");
|
||||
});
|
||||
|
||||
it("EditorToolbar.vue uses the saved executeSql shortcut", () => {
|
||||
expect(toolbarSource).toContain("formatShortcutDisplay(settingsStore.editorSettings.shortcuts.executeSql)");
|
||||
expect(toolbarSource).toMatch(/t\(\s*"toolbar\.executeShortcut"\s*,\s*\{\s*shortcut:\s*executeShortcutDisplay\.value/);
|
||||
});
|
||||
|
||||
it("EditorSettingsDialog.vue uses the currently edited executeSql shortcut", () => {
|
||||
expect(settingsDialogSource).toMatch(/function translateWithExecuteShortcut\([^)]*\)[^}]*formatShortcutDisplay\(editShortcuts\.value\.executeSql\)/);
|
||||
expect(settingsDialogSource).toContain('translateWithExecuteShortcut("settings.executeMode")');
|
||||
});
|
||||
|
||||
it("EditorSettingsDialog.vue uses the same edited shortcut in settings search", () => {
|
||||
expect(settingsDialogSource).toMatch(/resolveSettingsSearchEntries\(\s*\[[^\]]*\]\s*,\s*\{[^}]*\}\s*,\s*translateWithExecuteShortcut\s*,/s);
|
||||
});
|
||||
});
|
||||
@@ -144,7 +144,7 @@ export default {
|
||||
newConnection: "New Connection",
|
||||
newQuery: "New Query",
|
||||
execute: "Execute",
|
||||
executeShortcut: "Execute selection/query (Cmd+Enter)",
|
||||
executeShortcut: "Execute selection/query ({shortcut})",
|
||||
stopQuery: "Stop query",
|
||||
explainPlan: "Explain plan",
|
||||
stopExplain: "Stop explain",
|
||||
@@ -5855,7 +5855,7 @@ export default {
|
||||
resetAllDefaults: "Reset All Defaults",
|
||||
save: "Save",
|
||||
cancel: "Cancel",
|
||||
executeMode: "Execute Mode (Cmd+Enter)",
|
||||
executeMode: "Execute Mode ({shortcut})",
|
||||
executeModeAll: "Execute all SQL",
|
||||
executeModeCurrent: "Execute statement at cursor",
|
||||
executeAllOnBlankLine: "Execute all SQL from blank lines",
|
||||
|
||||
@@ -145,7 +145,7 @@ export default withEnglishFallback({
|
||||
newConnection: "Nueva conexión",
|
||||
newQuery: "Nueva consulta",
|
||||
execute: "Ejecutar",
|
||||
executeShortcut: "Ejecutar selección/consulta (Cmd+Enter)",
|
||||
executeShortcut: "Ejecutar selección/consulta ({shortcut})",
|
||||
stopQuery: "Detener consulta",
|
||||
explainPlan: "Plan de ejecución",
|
||||
stopExplain: "Detener análisis",
|
||||
@@ -5574,7 +5574,7 @@ export default withEnglishFallback({
|
||||
resetAllDefaults: "Restablecer todos los valores por defecto",
|
||||
save: "Guardar",
|
||||
cancel: "Cancelar",
|
||||
executeMode: "Modo de ejecución (Cmd+Enter)",
|
||||
executeMode: "Modo de ejecución ({shortcut})",
|
||||
executeModeAll: "Ejecutar todo el SQL",
|
||||
executeModeCurrent: "Ejecutar sentencia en el cursor",
|
||||
executeAllOnBlankLine: "Ejecutar todo el SQL desde líneas en blanco",
|
||||
|
||||
@@ -144,7 +144,7 @@ export default withEnglishFallback({
|
||||
newConnection: "Nuova Connessione",
|
||||
newQuery: "Nuova Query",
|
||||
execute: "Esegui",
|
||||
executeShortcut: "Esegui selezione/query (Cmd+Enter)",
|
||||
executeShortcut: "Esegui selezione/query ({shortcut})",
|
||||
stopQuery: "Interrompi query",
|
||||
explainPlan: "Spiega piano",
|
||||
stopExplain: "Interrompi spiegazione",
|
||||
@@ -5574,7 +5574,7 @@ export default withEnglishFallback({
|
||||
resetAllDefaults: "Ripristina Tutti i Predefiniti",
|
||||
save: "Salva",
|
||||
cancel: "Annulla",
|
||||
executeMode: "Modalità Esecuzione (Cmd+Enter)",
|
||||
executeMode: "Modalità Esecuzione ({shortcut})",
|
||||
executeModeAll: "Esegui tutto l'SQL",
|
||||
executeModeCurrent: "Esegui istruzione al cursore",
|
||||
executeAllOnBlankLine: "Esegui tutto l'SQL dalle righe vuote",
|
||||
|
||||
@@ -145,7 +145,7 @@ export default withEnglishFallback({
|
||||
newConnection: "新しい接続",
|
||||
newQuery: "新しいクエリ",
|
||||
execute: "実行",
|
||||
executeShortcut: "選択範囲/クエリを実行 (Cmd+Enter)",
|
||||
executeShortcut: "選択範囲/クエリを実行 ({shortcut})",
|
||||
stopQuery: "クエリを停止",
|
||||
explainPlan: "実行計画を表示",
|
||||
stopExplain: "実行計画の表示を停止",
|
||||
@@ -5601,7 +5601,7 @@ export default withEnglishFallback({
|
||||
resetAllDefaults: "すべての設定をリセット",
|
||||
save: "保存",
|
||||
cancel: "キャンセル",
|
||||
executeMode: "実行モード (Cmd+Enter)",
|
||||
executeMode: "実行モード ({shortcut})",
|
||||
executeModeAll: "すべてのSQLを実行",
|
||||
executeModeCurrent: "カーソル位置の文を実行",
|
||||
executeAllOnBlankLine: "空行ではすべてのSQLを実行",
|
||||
|
||||
@@ -145,7 +145,7 @@ export default withEnglishFallback({
|
||||
newConnection: "새 연결",
|
||||
newQuery: "새 쿼리",
|
||||
execute: "실행",
|
||||
executeShortcut: "선택 영역/쿼리 실행 (Cmd+Enter)",
|
||||
executeShortcut: "선택 영역/쿼리 실행 ({shortcut})",
|
||||
stopQuery: "쿼리 중지",
|
||||
explainPlan: "실행 계획",
|
||||
stopExplain: "실행 계획 중지",
|
||||
@@ -5333,7 +5333,7 @@ export default withEnglishFallback({
|
||||
resetAllDefaults: "모든 기본값 재설정",
|
||||
save: "저장",
|
||||
cancel: "취소",
|
||||
executeMode: "실행 모드 (Cmd+Enter)",
|
||||
executeMode: "실행 모드 ({shortcut})",
|
||||
executeModeAll: "모든 SQL 실행",
|
||||
executeModeCurrent: "커서 위치의 구문 실행",
|
||||
executeAllOnBlankLine: "빈 줄에서 모든 SQL 실행",
|
||||
|
||||
@@ -145,7 +145,7 @@ export default withEnglishFallback({
|
||||
newConnection: "Nova Conexão",
|
||||
newQuery: "Nova Consulta",
|
||||
execute: "Executar",
|
||||
executeShortcut: "Executar seleção/consulta (Cmd+Enter)",
|
||||
executeShortcut: "Executar seleção/consulta ({shortcut})",
|
||||
stopQuery: "Parar consulta",
|
||||
explainPlan: "Explicar plano",
|
||||
stopExplain: "Parar explicação",
|
||||
@@ -5576,7 +5576,7 @@ export default withEnglishFallback({
|
||||
resetAllDefaults: "Redefinir todos os padrões",
|
||||
save: "Salvar",
|
||||
cancel: "Cancelar",
|
||||
executeMode: "Modo de execução (Cmd+Enter)",
|
||||
executeMode: "Modo de execução ({shortcut})",
|
||||
executeModeAll: "Executar todo o SQL",
|
||||
executeModeCurrent: "Executar instrução no cursor",
|
||||
executeAllOnBlankLine: "Executar todo o SQL em linhas em branco",
|
||||
|
||||
@@ -69,7 +69,7 @@ export default withEnglishFallback({
|
||||
newConnection: "新建连接",
|
||||
newQuery: "新建查询",
|
||||
execute: "执行",
|
||||
executeShortcut: "执行选中/全部 (Cmd+Enter)",
|
||||
executeShortcut: "执行选中/全部 ({shortcut})",
|
||||
stopQuery: "停止执行",
|
||||
explainPlan: "执行计划",
|
||||
stopExplain: "停止执行计划",
|
||||
@@ -5841,7 +5841,7 @@ export default withEnglishFallback({
|
||||
resetAllDefaults: "恢复所有默认设置",
|
||||
save: "保存",
|
||||
cancel: "取消",
|
||||
executeMode: "执行模式 (Cmd+Enter)",
|
||||
executeMode: "执行模式 ({shortcut})",
|
||||
executeModeAll: "执行全部 SQL",
|
||||
executeModeCurrent: "执行光标所在语句",
|
||||
executeAllOnBlankLine: "空白位置执行全部 SQL",
|
||||
|
||||
@@ -145,7 +145,7 @@ export default withEnglishFallback({
|
||||
newConnection: "建立連線",
|
||||
newQuery: "建立查詢",
|
||||
execute: "執行",
|
||||
executeShortcut: "執行選取/全部 (Cmd+Enter)",
|
||||
executeShortcut: "執行選取/全部 ({shortcut})",
|
||||
stopQuery: "停止執行",
|
||||
explainPlan: "執行計畫",
|
||||
stopExplain: "停止執行計畫",
|
||||
@@ -4910,7 +4910,7 @@ export default withEnglishFallback({
|
||||
resetAllDefaults: "還原所有預設設定",
|
||||
save: "儲存",
|
||||
cancel: "取消",
|
||||
executeMode: "執行模式 (Cmd+Enter)",
|
||||
executeMode: "執行模式 ({shortcut})",
|
||||
executeModeAll: "執行全部 SQL",
|
||||
executeModeCurrent: "執行指標所在語句",
|
||||
executeAllOnBlankLine: "空白位置執行全部 SQL",
|
||||
|
||||
Reference in new issue
Block a user