From a20a51fa754be59d2abd34bdce3a27d8fa211926 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 11 May 2025 18:45:37 +0300 Subject: [PATCH] fix(code): indentation working in read-only mode --- packages/codemirror/src/extensions/custom_tab.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/codemirror/src/extensions/custom_tab.ts b/packages/codemirror/src/extensions/custom_tab.ts index 2b93d7678..2355ce90f 100644 --- a/packages/codemirror/src/extensions/custom_tab.ts +++ b/packages/codemirror/src/extensions/custom_tab.ts @@ -1,5 +1,5 @@ import { indentLess, indentMore } from "@codemirror/commands"; -import { EditorSelection, type ChangeSpec } from "@codemirror/state"; +import { EditorSelection, EditorState, type ChangeSpec } from "@codemirror/state"; import type { KeyBinding } from "@codemirror/view"; /** @@ -14,6 +14,10 @@ const smartIndentWithTab: KeyBinding[] = [ { key: "Tab", run({ state, dispatch }) { + if (state.facet(EditorState.readOnly)) { + return false; + } + const { selection } = state; const changes = []; const newSelections = [];