add user setting for sticky scroll

This commit is contained in:
Evan Simkowitz 2024-09-04 23:08:56 -07:00
parent 292a9ae1e5
commit e1a19a0b80
No known key found for this signature in database
4 changed files with 12 additions and 2 deletions

View File

@ -82,10 +82,16 @@ const minimapEnabledAtom = atom((get) => {
return settings["editor:minimapenabled"] ?? false;
});
const stickyScrollEnabledAtom = atom((get) => {
const settings = get(atoms.settingsAtom);
return settings["editor:stickyscrollenabled"] ?? false;
});
export function CodeEditor({ text, language, filename, onChange, onMount }: CodeEditorProps) {
const divRef = useRef<HTMLDivElement>(null);
const unmountRef = useRef<() => void>(null);
const minimapEnabled = useAtomValue(minimapEnabledAtom);
const stickyScrollEnabled = useAtomValue(stickyScrollEnabledAtom);
const theme = "wave-theme-dark";
React.useEffect(() => {
@ -112,8 +118,9 @@ export function CodeEditor({ text, language, filename, onChange, onMount }: Code
const editorOpts = useMemo(() => {
const opts = defaultEditorOptions();
opts.minimap.enabled = minimapEnabled;
opts.stickyScroll.enabled = stickyScrollEnabled;
return opts;
}, [minimapEnabled]);
}, [minimapEnabled, stickyScrollEnabled]);
return (
<div className="code-editor-wrapper">

View File

@ -396,6 +396,7 @@ declare global {
"term:fontfamily"?: string;
"term:disablewebgl"?: boolean;
"editor:minimapenabled"?: boolean;
"editor:stickyscrollenabled"?: boolean;
"web:*"?: boolean;
"web:openlinksinternally"?: boolean;
"blockheader:*"?: boolean;

View File

@ -20,6 +20,7 @@ const (
ConfigKey_TermDisableWebGl = "term:disablewebgl"
ConfigKey_EditorMinimapEnabled = "editor:minimapenabled"
ConfigKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled"
ConfigKey_WebClear = "web:*"
ConfigKey_WebOpenLinksInternally = "web:openlinksinternally"

View File

@ -52,6 +52,7 @@ type SettingsType struct {
TermDisableWebGl bool `json:"term:disablewebgl,omitempty"`
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"`
WebClear bool `json:"web:*,omitempty"`
WebOpenLinksInternally bool `json:"web:openlinksinternally,omitempty"`