File tree Expand file tree Collapse file tree 2 files changed +11
-13
lines changed
Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ onMounted(async () => {
105105 } else {
106106 watch (
107107 () => props .filename ,
108- () => {
108+ (_ , oldFilename ) => {
109109 if (! editorInstance ) return
110110 const file = store .state .files [props .filename ]
111111 if (! file ) return null
@@ -114,10 +114,16 @@ onMounted(async () => {
114114 file .language ,
115115 file .code
116116 )
117+
118+ const oldFile = oldFilename ? store .state .files [oldFilename ] : null
119+ if (oldFile ) {
120+ oldFile .editorViewState = editorInstance .saveViewState ()
121+ }
122+
117123 editorInstance .setModel (model )
118124
119- if (file .selection ) {
120- editorInstance .setSelection (file .selection )
125+ if (file .editorViewState ) {
126+ editorInstance .restoreViewState (file .editorViewState )
121127 editorInstance .focus ()
122128 }
123129 },
@@ -135,14 +141,6 @@ onMounted(async () => {
135141 emit (' change' , editorInstance .getValue ())
136142 })
137143
138- editorInstance .onDidChangeCursorSelection ((e ) => {
139- const selection = e .selection
140- const file = store .state .files [props .filename ]
141- if (file ) {
142- file .selection = selection
143- }
144- })
145-
146144 // update theme
147145 watch (replTheme , (n ) => {
148146 editorInstance .updateOptions ({
Original file line number Diff line number Diff line change 88 SFCTemplateCompileOptions ,
99} from 'vue/compiler-sfc'
1010import { OutputModes } from './output/types'
11- import type { Selection } from 'monaco-editor-core'
11+ import type { editor } from 'monaco-editor-core'
1212
1313const defaultMainFile = 'src/App.vue'
1414
@@ -52,7 +52,7 @@ export class File {
5252 css : '' ,
5353 ssr : '' ,
5454 }
55- selection : Selection | null = null
55+ editorViewState : editor . ICodeEditorViewState | null = null
5656
5757 constructor ( filename : string , code = '' , hidden = false ) {
5858 this . filename = filename
You can’t perform that action at this time.
0 commit comments