feat(editor): add toggle fold shortcut
This commit is contained in:
1 parent
1a6e00acbb
commit
b1f0784d49
11 files changed
+21
-1
No files matched your search
@@ -821,6 +821,7 @@ const formatterEditorShortcutIds: ShortcutActionId[] = [
|
||||
"selectAll",
|
||||
"uppercaseSelection",
|
||||
"lowercaseSelection",
|
||||
"toggleFold",
|
||||
];
|
||||
const formatterEditorShortcutDefinitions = computed(() => formatterEditorShortcutIds.map((id) => SHORTCUT_DEFINITIONS.find((definition) => definition.id === id)).filter((definition): definition is (typeof SHORTCUT_DEFINITIONS)[number] => !!definition));
|
||||
const filteredShortcutDefinitions = computed(() => {
|
||||
|
||||
@@ -356,6 +356,7 @@ let codeMirrorRedo: typeof import("@codemirror/commands").redo | null = null;
|
||||
let codeMirrorSelectAll: typeof import("@codemirror/commands").selectAll | null = null;
|
||||
let codeMirrorInsertNewlineKeepIndent: typeof import("@codemirror/commands").insertNewlineKeepIndent | null = null;
|
||||
let codeMirrorToggleLineComment: typeof import("@codemirror/commands").toggleLineComment | null = null;
|
||||
let codeMirrorToggleFold: typeof import("@codemirror/language").toggleFold | null = null;
|
||||
let pendingCompletionTabTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let setSqlDiagnosticsEffect: import("@codemirror/state").StateEffectType<SqlSemanticDiagnostic[]> | null = null;
|
||||
let setPreviewRangeEffect:
|
||||
@@ -1395,6 +1396,7 @@ function runKeymapExtension(codeMirrorKeymap: (typeof import("@codemirror/view")
|
||||
...binding(shortcuts.uppercaseSelection, () => convertSelectedSqlCase("upper")),
|
||||
...binding(shortcuts.lowercaseSelection, () => convertSelectedSqlCase("lower")),
|
||||
...binding(shortcuts.toggleLineComment, (view) => codeMirrorToggleLineComment?.(view) ?? false),
|
||||
...binding(shortcuts.toggleFold, (view) => codeMirrorToggleFold?.(view) ?? false),
|
||||
...binding(shortcuts.exPasteSqlInCondition, () => {
|
||||
if (!supportsSqlInListPaste(props.databaseType)) return false;
|
||||
void pasteClipboardAsSqlInCondition();
|
||||
@@ -3392,7 +3394,7 @@ onMounted(async () => {
|
||||
langSql,
|
||||
{ autocompletion, startCompletion, acceptCompletion, closeBrackets, closeBracketsKeymap, snippetCompletion, completionStatus, completionKeymap, insertCompletionText, nextSnippetField },
|
||||
{ copyLineDown, copyLineUp, deleteLine, indentLess, indentMore, insertNewlineKeepIndent, moveLineDown, moveLineUp, redo, selectAll, undo, toggleLineComment, history, defaultKeymap, historyKeymap },
|
||||
{ bracketMatching, foldGutter, indentOnInput, indentUnit, syntaxHighlighting, defaultHighlightStyle, foldKeymap, ensureSyntaxTree },
|
||||
{ bracketMatching, foldGutter, indentOnInput, indentUnit, syntaxHighlighting, defaultHighlightStyle, foldKeymap, toggleFold, ensureSyntaxTree },
|
||||
{ searchKeymap },
|
||||
] = await Promise.all([import("@codemirror/view"), import("@codemirror/state"), import("@codemirror/lang-sql"), import("@codemirror/autocomplete"), import("@codemirror/commands"), import("@codemirror/language"), import("@codemirror/search")]);
|
||||
editorViewModule = {
|
||||
@@ -3439,6 +3441,7 @@ onMounted(async () => {
|
||||
codeMirrorSelectAll = selectAll;
|
||||
codeMirrorInsertNewlineKeepIndent = insertNewlineKeepIndent;
|
||||
codeMirrorToggleLineComment = toggleLineComment;
|
||||
codeMirrorToggleFold = toggleFold;
|
||||
codeMirrorIndentUnit = indentUnit;
|
||||
window.addEventListener("keyup", clearTableNavigationHoverOnModifierRelease);
|
||||
window.addEventListener("blur", clearTableNavigationHover);
|
||||
|
||||
@@ -4642,6 +4642,7 @@ export default {
|
||||
shortcutEditSidebarConnection: "Edit sidebar connection",
|
||||
shortcutOpenDataInNewTab: "Open data in new tab (mouse click)",
|
||||
shortcutSendSelectionToAi: "Send selection to AI",
|
||||
shortcutToggleFold: "Toggle fold",
|
||||
shortcutScopeGlobal: "Global",
|
||||
shortcutScopeEditor: "SQL editor",
|
||||
shortcutScopeGrid: "Data grid",
|
||||
|
||||
@@ -4397,6 +4397,7 @@ export default withEnglishFallback({
|
||||
shortcutEditSidebarConnection: "Editar conexión de la barra lateral",
|
||||
shortcutOpenDataInNewTab: "Abrir datos en una pestaña nueva (clic del ratón)",
|
||||
shortcutSendSelectionToAi: "Enviar selección a IA",
|
||||
shortcutToggleFold: "Contraer/expandir código",
|
||||
shortcutScopeGlobal: "Global",
|
||||
shortcutScopeEditor: "Editor SQL",
|
||||
shortcutScopeGrid: "Cuadrícula de datos",
|
||||
|
||||
@@ -4395,6 +4395,7 @@ export default withEnglishFallback({
|
||||
shortcutEditSidebarConnection: "Modifica connessione barra laterale",
|
||||
shortcutOpenDataInNewTab: "Apri dati in una nuova scheda (clic del mouse)",
|
||||
shortcutSendSelectionToAi: "Invia selezione ad AI",
|
||||
shortcutToggleFold: "Comprimi/espandi codice",
|
||||
shortcutScopeGlobal: "Globale",
|
||||
shortcutScopeEditor: "Editor SQL",
|
||||
shortcutScopeGrid: "Griglia dati",
|
||||
|
||||
@@ -4379,6 +4379,7 @@ export default withEnglishFallback({
|
||||
shortcutEditSidebarConnection: "サイドバー接続を編集",
|
||||
shortcutOpenDataInNewTab: "新しいデータタブで開く(マウスクリック)",
|
||||
shortcutSendSelectionToAi: "選択範囲をAIに送信",
|
||||
shortcutToggleFold: "折りたたみの切り替え",
|
||||
shortcutScopeGlobal: "グローバル",
|
||||
shortcutScopeEditor: "SQLエディタ",
|
||||
shortcutScopeGrid: "データグリッド",
|
||||
|
||||
@@ -4397,6 +4397,7 @@ export default withEnglishFallback({
|
||||
shortcutEditSidebarConnection: "Editar conexão da barra lateral",
|
||||
shortcutOpenDataInNewTab: "Abrir dados em nova aba (clique do mouse)",
|
||||
shortcutSendSelectionToAi: "Enviar seleção para IA",
|
||||
shortcutToggleFold: "Recolher/expandir código",
|
||||
shortcutScopeGlobal: "Global",
|
||||
shortcutScopeEditor: "Editor SQL",
|
||||
shortcutScopeGrid: "Grade de dados",
|
||||
|
||||
@@ -4644,6 +4644,7 @@ export default withEnglishFallback({
|
||||
shortcutEditSidebarConnection: "编辑侧边栏连接",
|
||||
shortcutOpenDataInNewTab: "在新数据标签页中打开(鼠标点击)",
|
||||
shortcutSendSelectionToAi: "发送选中代码到 AI",
|
||||
shortcutToggleFold: "切换折叠",
|
||||
shortcutScopeGlobal: "全局",
|
||||
shortcutScopeEditor: "SQL 编辑器",
|
||||
shortcutScopeGrid: "数据表格",
|
||||
|
||||
@@ -4052,6 +4052,7 @@ export default withEnglishFallback({
|
||||
shortcutEditSidebarConnection: "編輯側邊欄連線",
|
||||
shortcutOpenDataInNewTab: "在新資料分頁中開啟(滑鼠點擊)",
|
||||
shortcutSendSelectionToAi: "傳送選取程式碼至 AI",
|
||||
shortcutToggleFold: "切換折疊",
|
||||
shortcutScopeGlobal: "全域",
|
||||
shortcutScopeEditor: "SQL 編輯器",
|
||||
shortcutScopeGrid: "資料表格",
|
||||
|
||||
@@ -19,6 +19,7 @@ describe("shortcutRegistry editor actions", () => {
|
||||
"uppercaseSelection",
|
||||
"lowercaseSelection",
|
||||
"exPasteSqlInCondition",
|
||||
"toggleFold",
|
||||
];
|
||||
const sidebarShortcutActionIds: ShortcutActionId[] = ["copySidebarSelection", "pasteSidebarSelection", "editSidebarConnection"];
|
||||
|
||||
@@ -100,6 +101,7 @@ describe("shortcutRegistry editor actions", () => {
|
||||
expect(shortcuts.uppercaseSelection).toBe("Shift+Alt+U");
|
||||
expect(shortcuts.lowercaseSelection).toBe("Shift+Alt+L");
|
||||
expect(shortcuts.exPasteSqlInCondition).toBe("");
|
||||
expect(shortcuts.toggleFold).toBe("Mod+.");
|
||||
});
|
||||
|
||||
it("detects conflicts between formatter editor shortcuts and other editor shortcuts", () => {
|
||||
|
||||
@@ -21,6 +21,7 @@ export type ShortcutActionId =
|
||||
| "uppercaseSelection"
|
||||
| "lowercaseSelection"
|
||||
| "exPasteSqlInCondition"
|
||||
| "toggleFold"
|
||||
| "copyCurrentRow"
|
||||
| "deleteCurrentRow"
|
||||
| "newQuery"
|
||||
@@ -202,6 +203,12 @@ export const SHORTCUT_DEFINITIONS: ShortcutDefinition[] = [
|
||||
scope: "editor",
|
||||
defaultShortcut: "",
|
||||
},
|
||||
{
|
||||
id: "toggleFold",
|
||||
labelKey: "settings.shortcutToggleFold",
|
||||
scope: "editor",
|
||||
defaultShortcut: "Mod+.",
|
||||
},
|
||||
{
|
||||
id: "copyCurrentRow",
|
||||
labelKey: "settings.shortcutCopyCurrentRow",
|
||||
|
||||
Reference in new issue
Block a user