feat(appearance): apply UI zoom level to terminal and Monaco editors
Extend the existing appearance zoom setting so it also scales xterm.js terminals and Monaco editors (diff viewer, three-pane merge editor, file workspace editor), which previously rendered at a hard-coded 13px regardless of zoom. - Terminals read zoom at init and update term.options.fontSize live on zoom change, refitting after a double rAF so xterm's renderer has recomputed cell metrics. Font size is rounded to an integer to avoid subpixel blur in the canvas renderer. - Monaco editors derive fontSize from zoomLevel; three-pane merge editor memoizes its options object to avoid redundant updateOptions calls on unrelated re-renders.
This commit is contained in:
@@ -6,8 +6,11 @@ import { ChevronLeft, ChevronRight } from "lucide-react"
|
||||
import type { DiffOnMount } from "@monaco-editor/react"
|
||||
import type { editor as MonacoEditorNs } from "monaco-editor"
|
||||
import { defineMonacoThemes, useMonacoThemeSync } from "@/lib/monaco-themes"
|
||||
import { useZoomLevel } from "@/hooks/use-appearance"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const EDITOR_BASE_FONT_SIZE = 13
|
||||
|
||||
import "@/lib/monaco-local"
|
||||
|
||||
const MonacoDiffEditor = dynamic(
|
||||
@@ -36,6 +39,7 @@ export function DiffViewer({
|
||||
className,
|
||||
}: DiffViewerProps) {
|
||||
const editorTheme = useMonacoThemeSync()
|
||||
const { zoomLevel } = useZoomLevel()
|
||||
const diffEditorRef = useRef<MonacoEditorNs.IStandaloneDiffEditor | null>(
|
||||
null
|
||||
)
|
||||
@@ -187,7 +191,7 @@ export function DiffViewer({
|
||||
renderSideBySide: true,
|
||||
renderSideBySideInlineBreakpoint: 0,
|
||||
automaticLayout: true,
|
||||
fontSize: 13,
|
||||
fontSize: (EDITOR_BASE_FONT_SIZE * zoomLevel) / 100,
|
||||
minimap: { enabled: false },
|
||||
scrollBeyondLastLine: false,
|
||||
renderOverviewRuler: false,
|
||||
|
||||
Reference in New Issue
Block a user