Skip to content

Commit

Permalink
feat: hitting tab key inserts a tab in codemirror (#2477)
Browse files Browse the repository at this point in the history
Fixes #2458

Before, tabbing would change the focus to the next element on the page.
This adds the correct key binding so that hitting tab within the
codemirror editor actually inserts 2 spaces.
  • Loading branch information
deniseli authored Aug 21, 2024
1 parent 549b493 commit 2a797e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { autocompletion, closeBrackets, closeBracketsKeymap } from '@codemirror/
import { atomone } from '@uiw/codemirror-theme-atomone'
import { githubLight } from '@uiw/codemirror-theme-github'

import { defaultKeymap } from '@codemirror/commands'
import { defaultKeymap, indentWithTab } from '@codemirror/commands'
import { handleRefresh, jsonSchemaHover, jsonSchemaLinter, stateExtensions } from 'codemirror-json-schema'
import { json5, json5ParseLinter } from 'codemirror-json5'
import { useCallback, useEffect, useRef } from 'react'
Expand All @@ -21,7 +21,7 @@ const commonExtensions = [
bracketMatching(),
highlightActiveLineGutter(),
closeBrackets(),
keymap.of([...closeBracketsKeymap, ...foldKeymap, ...lintKeymap, ...defaultKeymap]),
keymap.of([indentWithTab, ...closeBracketsKeymap, ...foldKeymap, ...lintKeymap, ...defaultKeymap]),
EditorView.lineWrapping,
EditorState.tabSize.of(2),
]
Expand Down

0 comments on commit 2a797e5

Please sign in to comment.