@@ -105,26 +105,26 @@ onMounted(async () => {
105
105
editor .value = editorInstance
106
106
107
107
// Support for semantic highlighting
108
- const t = (editorInstance as any )._themeService ._theme ;
108
+ const t = (editorInstance as any )._themeService ._theme
109
109
t .getTokenStyleMetadata = (
110
110
type : string ,
111
111
modifiers : string [],
112
112
_language : string
113
113
) => {
114
- const _readonly = modifiers .includes (' readonly' );
114
+ const _readonly = modifiers .includes (' readonly' )
115
115
switch (type ) {
116
116
case ' function' :
117
117
case ' method' :
118
- return { foreground: 12 };
118
+ return { foreground: 12 }
119
119
case ' class' :
120
- return { foreground: 11 };
120
+ return { foreground: 11 }
121
121
case ' variable' :
122
122
case ' property' :
123
- return { foreground: _readonly ? 21 : 9 };
123
+ return { foreground: _readonly ? 21 : 9 }
124
124
default :
125
- return { foreground: 0 };
125
+ return { foreground: 0 }
126
126
}
127
- };
127
+ }
128
128
129
129
if (props .readonly ) {
130
130
watch (
@@ -147,6 +147,11 @@ onMounted(async () => {
147
147
file .code
148
148
)
149
149
editorInstance .setModel (model )
150
+
151
+ if (file .selection ) {
152
+ editorInstance .setSelection (file .selection )
153
+ editorInstance .focus ()
154
+ }
150
155
},
151
156
{ immediate: true }
152
157
)
@@ -161,6 +166,14 @@ onMounted(async () => {
161
166
editorInstance .onDidChangeModelContent (() => {
162
167
emits (' change' , editorInstance .getValue ())
163
168
})
169
+
170
+ editorInstance .onDidChangeCursorSelection (e => {
171
+ const selection = e .selection
172
+ const file = store .state .files [props .filename ]
173
+ if (file ) {
174
+ file .selection = selection
175
+ }
176
+ })
164
177
})
165
178
166
179
onBeforeUnmount (() => {
0 commit comments