fix(code): indentation working in read-only mode

This commit is contained in:
Elian Doran 2025-05-11 18:45:37 +03:00
parent 3e5e19b8a5
commit a20a51fa75
No known key found for this signature in database

View File

@ -1,5 +1,5 @@
import { indentLess, indentMore } from "@codemirror/commands"; 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"; import type { KeyBinding } from "@codemirror/view";
/** /**
@ -14,6 +14,10 @@ const smartIndentWithTab: KeyBinding[] = [
{ {
key: "Tab", key: "Tab",
run({ state, dispatch }) { run({ state, dispatch }) {
if (state.facet(EditorState.readOnly)) {
return false;
}
const { selection } = state; const { selection } = state;
const changes = []; const changes = [];
const newSelections = []; const newSelections = [];