diff --git a/scripts/editor.checks.test.ts b/scripts/editor.checks.test.ts index 66c833d5..5734c0bb 100644 --- a/scripts/editor.checks.test.ts +++ b/scripts/editor.checks.test.ts @@ -225,6 +225,7 @@ describe('editor option wiring', () => { /** A settled settings store, so each test names only the field it is about. */ const SETTINGS = { minimap: false, + stickyScroll: true, wordWrap: 'on', editorMaxWidth: 80, lineNumbers: 'on', @@ -303,6 +304,7 @@ describe('editor option wiring', () => { 'renderWhitespace', 'selectionHighlight', 'smoothScrolling', + 'stickyScroll', 'wordWrap', 'wordWrapColumn', 'wrappingStrategy', diff --git a/scripts/editor.test.ts b/scripts/editor.test.ts index f8ca71e6..74390bbb 100644 --- a/scripts/editor.test.ts +++ b/scripts/editor.test.ts @@ -125,6 +125,7 @@ describe('editor options', () => { /** A settled settings store, so each test names only the field it is about. */ const SETTINGS = { minimap: false, + stickyScroll: true, wordWrap: 'on', editorMaxWidth: 80, lineNumbers: 'on', @@ -138,6 +139,13 @@ describe('editor options', () => { typewriterMode: false, }; + test('Sticky Headings reaches the editor that is already open', () => { + // It was set in the creation literal only, so turning the setting on or off + // changed nothing until the next editor was created. + assert.deepEqual(editorOptionsFromSettings(SETTINGS, 100).stickyScroll, { enabled: true }); + assert.deepEqual(editorOptionsFromSettings({ ...SETTINGS, stickyScroll: false }, 100).stickyScroll, { enabled: false }); + }); + test('the caret glide is a setting and not a hard-coded on', () => { // It was `cursorSmoothCaretAnimation: 'on'` in the creation literal (#710), // which is why the assertion below is about `editorOptionsFromSettings` and diff --git a/src/lib/components/Editor.svelte b/src/lib/components/Editor.svelte index 3f03b824..464b8467 100644 --- a/src/lib/components/Editor.svelte +++ b/src/lib/components/Editor.svelte @@ -363,7 +363,6 @@ ...editorOptionsFromSettings(settings, zoomLevel), readOnly, scrollBeyondLastLine: true, - stickyScroll: { enabled: settings.stickyScroll }, wordBasedSuggestions: "off", quickSuggestions: false, // Monaco's Unicode highlighter is built for source code, where a diff --git a/src/lib/utils/editorOptions.ts b/src/lib/utils/editorOptions.ts index 632c20f0..d947a687 100644 --- a/src/lib/utils/editorOptions.ts +++ b/src/lib/utils/editorOptions.ts @@ -98,12 +98,14 @@ export function editorOptionsFromSettings( // cursor line. 'all' applies it to clicks too, not only to keyboard moves. cursorSurroundingLines: settings.typewriterMode ? TYPEWRITER_SURROUNDING_LINES : 0, cursorSurroundingLinesStyle: settings.typewriterMode ? "all" : "default", + stickyScroll: { enabled: settings.stickyScroll }, }; } /** The slice of the settings store the options above are derived from. */ export type EditorOptionSettings = { minimap: boolean; + stickyScroll: boolean; wordWrap: string; editorMaxWidth: number; lineNumbers: string;