Skip to content

Commit ef5285f

Browse files
authored
fix: align fold gutter markers (#422)
1 parent de544a0 commit ef5285f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/components/editor.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { javascript } from "@codemirror/lang-javascript";
33
import { markdown } from "@codemirror/lang-markdown";
44
import { css } from "@codemirror/lang-css";
55
import { html } from "@codemirror/lang-html";
6+
import { foldGutter, type LanguageSupport } from "@codemirror/language";
67
import { EditorView } from "@codemirror/view";
7-
import { LanguageSupport } from "@codemirror/language";
8-
import CodeMirror from "@uiw/react-codemirror";
8+
import CodeMirror, { type BasicSetupOptions } from "@uiw/react-codemirror";
99
import { useEffect, useRef, useState, useMemo, type FC } from "react";
1010
import { useExplorer, type Language } from "@/hooks/use-explorer";
1111
import { mergeClassNames, debounce } from "@/lib/utils";
@@ -27,6 +27,15 @@ const languageExtensions: Record<
2727
html: () => html(),
2828
};
2929

30+
const foldGutterExtension = foldGutter({
31+
closedText: "▸",
32+
openText: "▾",
33+
});
34+
35+
const basicSetup: BasicSetupOptions = {
36+
foldGutter: false,
37+
};
38+
3039
type EditorProperties = {
3140
ariaLabel: string;
3241
readOnly?: boolean;
@@ -56,6 +65,7 @@ export const Editor: FC<EditorProperties> = ({
5665
const editorExtensions = useMemo(
5766
() => [
5867
activeLanguageExtension,
68+
foldGutterExtension,
5969
wrap ? EditorView.lineWrapping : [],
6070
EditorView.contentAttributes.of({ "aria-label": ariaLabel }),
6171
ESLintPlaygroundTheme,
@@ -181,6 +191,7 @@ export const Editor: FC<EditorProperties> = ({
181191
extensions={editorExtensions}
182192
onChange={debouncedOnChange}
183193
readOnly={readOnly}
194+
basicSetup={basicSetup}
184195
/>
185196
</div>
186197
);

0 commit comments

Comments
 (0)