]> source.dussan.org Git - gitea.git/commitdiff
Enable Monaco automaticLayout (#21515)
authorsilverwind <me@silverwind.io>
Thu, 20 Oct 2022 01:54:18 +0000 (03:54 +0200)
committerGitHub <noreply@github.com>
Thu, 20 Oct 2022 01:54:18 +0000 (02:54 +0100)
Enable
[`automaticLayout`](https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IDiffEditorOptions.html#automaticLayout)
for monaco so it can reflow itself.

Fixes: https://github.com/go-gitea/gitea/issues/21508
web_src/js/features/codeeditor.js

index a22043c9d48253032baf5b4c227bc3800d918f36..0366afc2c092d07868968057e4c832290d99f5e7 100644 (file)
@@ -17,6 +17,7 @@ const baseOptions = {
   rulers: false,
   scrollbar: {horizontalScrollbarSize: 6, verticalScrollbarSize: 6},
   scrollBeyondLastLine: false,
+  automaticLayout: true,
 };
 
 function getEditorconfig(input) {
@@ -111,10 +112,6 @@ export async function createMonaco(textarea, filename, editorOpts) {
     textarea.dispatchEvent(new Event('change')); // seems to be needed for jquery-are-you-sure
   });
 
-  window.addEventListener('resize', () => {
-    editor.layout();
-  });
-
   exportEditor(editor);
 
   const loading = document.querySelector('.editor-loading');