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 () => {
105
105
} else {
106
106
watch (
107
107
() => props .filename ,
108
- () => {
108
+ (_ , oldFilename ) => {
109
109
if (! editorInstance ) return
110
110
const file = store .state .files [props .filename ]
111
111
if (! file ) return null
@@ -114,10 +114,16 @@ onMounted(async () => {
114
114
file .language ,
115
115
file .code
116
116
)
117
+
118
+ const oldFile = oldFilename ? store .state .files [oldFilename ] : null
119
+ if (oldFile ) {
120
+ oldFile .editorViewState = editorInstance .saveViewState ()
121
+ }
122
+
117
123
editorInstance .setModel (model )
118
124
119
- if (file .selection ) {
120
- editorInstance .setSelection (file .selection )
125
+ if (file .editorViewState ) {
126
+ editorInstance .restoreViewState (file .editorViewState )
121
127
editorInstance .focus ()
122
128
}
123
129
},
@@ -135,14 +141,6 @@ onMounted(async () => {
135
141
emit (' change' , editorInstance .getValue ())
136
142
})
137
143
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
-
146
144
// update theme
147
145
watch (replTheme , (n ) => {
148
146
editorInstance .updateOptions ({
Original file line number Diff line number Diff line change 8
8
SFCTemplateCompileOptions ,
9
9
} from 'vue/compiler-sfc'
10
10
import { OutputModes } from './output/types'
11
- import type { Selection } from 'monaco-editor-core'
11
+ import type { editor } from 'monaco-editor-core'
12
12
13
13
const defaultMainFile = 'src/App.vue'
14
14
@@ -52,7 +52,7 @@ export class File {
52
52
css : '' ,
53
53
ssr : '' ,
54
54
}
55
- selection : Selection | null = null
55
+ editorViewState : editor . ICodeEditorViewState | null = null
56
56
57
57
constructor ( filename : string , code = '' , hidden = false ) {
58
58
this . filename = filename
You can’t perform that action at this time.
0 commit comments