[CB] Support real tab characters in SQL Editor (#4298)

* dbeaver/pro#7864 adds tabulation with actual tab indent for code mirror

* adds EDITOR_INDENT_UNIT to unify indent for sql editor and vqb
This commit is contained in:
sergeyteleshev
2026-04-22 12:35:53 +02:00
committed by GitHub
parent acc3e42f1c
commit a2ccd0b0f7
2 changed files with 8 additions and 2 deletions
@@ -37,6 +37,7 @@ export const Editor = observer<IEditorProps & IDefaultExtensions, IEditorRef>(
keymap,
lineWrapping,
search,
tabIndentation,
...rest
},
ref,
@@ -61,6 +62,7 @@ export const Editor = observer<IEditorProps & IDefaultExtensions, IEditorRef>(
keymap,
lineWrapping,
search,
tabIndentation,
});
extensions.set(...defaultExtensions);
@@ -1,12 +1,12 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2025 DBeaver Corp and others
* Copyright (C) 2020-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import { defaultKeymap, indentWithTab } from '@codemirror/commands';
import { bracketMatching, foldGutter, indentOnInput, syntaxHighlighting } from '@codemirror/language';
import { bracketMatching, foldGutter, indentOnInput, indentUnit, syntaxHighlighting } from '@codemirror/language';
import { highlightSelectionMatches, searchKeymap } from '@codemirror/search';
import { Compartment, type Extension } from '@codemirror/state';
import {
@@ -29,6 +29,7 @@ import { clsx } from '@dbeaver/ui-kit';
// @TODO allow to configure bindings outside of the component
const DEFAULT_KEY_MAP = defaultKeymap.filter(binding => binding.mac !== 'Ctrl-f' && binding.key !== 'Mod-Enter');
export const EDITOR_INDENT_UNIT = '\t';
DEFAULT_KEY_MAP.push(indentWithTab);
DEFAULT_KEY_MAP.push({
@@ -54,6 +55,7 @@ const defaultExtensionsFlags: IDefaultExtensions = {
keymap: true,
lineWrapping: false,
search: true,
tabIndentation: true,
};
export interface IDefaultExtensions {
@@ -73,6 +75,7 @@ export interface IDefaultExtensions {
keymap?: boolean;
lineWrapping?: boolean;
search?: boolean;
tabIndentation?: boolean;
}
const extensionMap = {
@@ -109,6 +112,7 @@ const extensionMap = {
rectangularSelection,
keymap: () => keymap.of(DEFAULT_KEY_MAP),
lineWrapping: () => EditorView.lineWrapping,
tabIndentation: () => indentUnit.of(EDITOR_INDENT_UNIT),
};
const DEFAULT_EXTENSIONS_COMPARTMENT = new Compartment();