@@ -16,7 +16,6 @@ import {
1616 highlightWhitespace ,
1717 keymap ,
1818 lineNumbers ,
19- scrollPastEnd ,
2019} from "@codemirror/view" ;
2120import {
2221 abbreviationTracker ,
@@ -27,6 +26,7 @@ import {
2726 wrapWithAbbreviation ,
2827} from "@emmetio/codemirror6-plugin" ;
2928import createBaseExtensions from "cm/baseExtensions" ;
29+ import createMainEditorExtensions from "cm/mainEditorExtensions" ;
3030import {
3131 setKeyBindings as applyKeyBindings ,
3232 executeCommand ,
@@ -163,12 +163,6 @@ async function EditorManager($header, $body) {
163163 } ,
164164 } ) ;
165165
166- // Make CodeMirror fill the container height and manage scrolling internally
167- const fixedHeightTheme = EditorView . theme ( {
168- "&" : { height : "100%" } ,
169- ".cm-scroller" : { height : "100%" , overflow : "auto" } ,
170- } ) ;
171-
172166 const pointerCursorVisibilityExtension = EditorView . updateListener . of (
173167 ( update ) => {
174168 if ( ! update . selectionSet ) return ;
@@ -764,24 +758,25 @@ async function EditorManager($header, $body) {
764758 // Create minimal CodeMirror editor
765759 const editorState = EditorState . create ( {
766760 doc : "" ,
767- extensions : [
761+ extensions : createMainEditorExtensions ( {
768762 // Emmet needs highest precedence so place before default keymaps
769- ...createEmmetExtensionSet ( { syntax : EmmetKnownSyntax . html } ) ,
770- ...createBaseExtensions ( ) ,
771- getCommandKeymapExtension ( ) ,
772- // Default theme
773- themeCompartment . of ( oneDark ) ,
774- fixedHeightTheme ,
775- scrollPastEnd ( ) ,
763+ emmetExtensions : createEmmetExtensionSet ( {
764+ syntax : EmmetKnownSyntax . html ,
765+ } ) ,
766+ baseExtensions : createBaseExtensions ( ) ,
767+ commandKeymapExtension : getCommandKeymapExtension ( ) ,
768+ themeExtension : themeCompartment . of ( oneDark ) ,
776769 pointerCursorVisibilityExtension,
777770 shiftClickSelectionExtension,
778771 touchSelectionUpdateExtension,
779- search ( ) ,
772+ searchExtension : search ( ) ,
780773 // Ensure read-only can be toggled later via compartment
781- readOnlyCompartment . of ( EditorState . readOnly . of ( false ) ) ,
774+ readOnlyExtension : readOnlyCompartment . of (
775+ EditorState . readOnly . of ( false ) ,
776+ ) ,
782777 // Editor options driven by settings via compartments
783- ... getBaseExtensionsFromOptions ( ) ,
784- ] ,
778+ optionExtensions : getBaseExtensionsFromOptions ( ) ,
779+ } ) ,
785780 } ) ;
786781
787782 const editor = new EditorView ( {
@@ -1128,22 +1123,20 @@ async function EditorManager($header, $body) {
11281123 function applyFileToEditor ( file ) {
11291124 if ( ! file || file . type !== "editor" ) return ;
11301125 const syntax = getEmmetSyntaxForFile ( file ) ;
1131- const baseExtensions = [
1126+ const baseExtensions = createMainEditorExtensions ( {
11321127 // Emmet needs to precede default keymaps so tracker Tab wins over indent
1133- ... createEmmetExtensionSet ( { syntax } ) ,
1134- ... createBaseExtensions ( ) ,
1135- getCommandKeymapExtension ( ) ,
1128+ emmetExtensions : createEmmetExtensionSet ( { syntax } ) ,
1129+ baseExtensions : createBaseExtensions ( ) ,
1130+ commandKeymapExtension : getCommandKeymapExtension ( ) ,
11361131 // keep compartment in the state to allow dynamic theme changes later
1137- themeCompartment . of ( oneDark ) ,
1138- fixedHeightTheme ,
1139- scrollPastEnd ( ) ,
1132+ themeExtension : themeCompartment . of ( oneDark ) ,
11401133 pointerCursorVisibilityExtension,
11411134 shiftClickSelectionExtension,
11421135 touchSelectionUpdateExtension,
1143- search ( ) ,
1136+ searchExtension : search ( ) ,
11441137 // Keep dynamic compartments across state swaps
1145- ... getBaseExtensionsFromOptions ( ) ,
1146- ] ;
1138+ optionExtensions : getBaseExtensionsFromOptions ( ) ,
1139+ } ) ;
11471140 const exts = [ ...baseExtensions ] ;
11481141 maybeAttachEmmetCompletions ( exts , syntax ) ;
11491142 try {
0 commit comments