From 4cd56f6fabb845c658c72667b1590dffa7f1dfb1 Mon Sep 17 00:00:00 2001 From: cfngc4594 Date: Sun, 23 Feb 2025 15:05:30 +0800 Subject: [PATCH] refactor(option): Rename code-editor-options.ts to option.ts and add wordWrap option Renamed code-editor-options.ts to option.ts and added the wordWrap: "on" option to enable word wrapping in the code editor. --- src/components/code-editor.tsx | 2 +- src/constants/{code-editor-options.ts => option.ts} | 13 +++++++++---- src/store/useCodeEditor.ts | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) rename src/constants/{code-editor-options.ts => option.ts} (81%) diff --git a/src/components/code-editor.tsx b/src/components/code-editor.tsx index 24ca1ae..6526ea1 100644 --- a/src/components/code-editor.tsx +++ b/src/components/code-editor.tsx @@ -8,7 +8,7 @@ import { highlighter } from "@/lib/shiki"; import { DEFAULT_VALUE } from "@/config/value"; import { shikiToMonaco } from "@shikijs/monaco"; import { Skeleton } from "@/components/ui/skeleton"; -import { CODE_EDITOR_OPTIONS } from "@/constants/code-editor-options"; +import { CODE_EDITOR_OPTIONS } from "@/constants/option"; import { SUPPORTED_LANGUAGE_SERVERS } from "@/config/language-server"; import { useCodeEditorOption, useCodeEditorState } from "@/store/useCodeEditor"; import { toSocket, WebSocketMessageReader, WebSocketMessageWriter } from "vscode-ws-jsonrpc"; diff --git a/src/constants/code-editor-options.ts b/src/constants/option.ts similarity index 81% rename from src/constants/code-editor-options.ts rename to src/constants/option.ts index 263106e..55d87db 100644 --- a/src/constants/code-editor-options.ts +++ b/src/constants/option.ts @@ -7,19 +7,24 @@ export const CODE_EDITOR_OPTIONS: monaco.editor.IEditorConstructionOptions = { fontFamily: "Fira Code", fontLigatures: true, fontSize: 14, - lineHeight: 20, + guides: { + bracketPairs: true, + indentation: true, + }, hideCursorInOverviewRuler: true, + lineHeight: 20, matchBrackets: "always", minimap: { enabled: false }, - wordWrap: "on", padding: { - top: 18 + top: 8 }, readOnly: false, scrollbar: { horizontalSliderSize: 4, verticalSliderSize: 18 - } + }, + showFoldingControls: "always", + wordWrap: "on", } diff --git a/src/store/useCodeEditor.ts b/src/store/useCodeEditor.ts index d4e86e5..58e5e23 100644 --- a/src/store/useCodeEditor.ts +++ b/src/store/useCodeEditor.ts @@ -1,9 +1,9 @@ import { create } from "zustand"; import * as monaco from "monaco-editor"; import { DEFAULT_LANGUAGE } from "@/config/language"; +import { CODE_EDITOR_OPTIONS } from "@/constants/option"; import { SupportedLanguage } from "@/constants/language"; import { MonacoLanguageClient } from "monaco-languageclient"; -import { CODE_EDITOR_OPTIONS } from "@/constants/code-editor-options"; interface CodeEditorState { language: SupportedLanguage;