@@ -105,26 +105,26 @@ onMounted(async () => {
105105 editor .value = editorInstance
106106
107107 // Support for semantic highlighting
108- const t = (editorInstance as any )._themeService ._theme ;
108+ const t = (editorInstance as any )._themeService ._theme
109109 t .getTokenStyleMetadata = (
110110 type : string ,
111111 modifiers : string [],
112112 _language : string
113113 ) => {
114- const _readonly = modifiers .includes (' readonly' );
114+ const _readonly = modifiers .includes (' readonly' )
115115 switch (type ) {
116116 case ' function' :
117117 case ' method' :
118- return { foreground: 12 };
118+ return { foreground: 12 }
119119 case ' class' :
120- return { foreground: 11 };
120+ return { foreground: 11 }
121121 case ' variable' :
122122 case ' property' :
123- return { foreground: _readonly ? 21 : 9 };
123+ return { foreground: _readonly ? 21 : 9 }
124124 default :
125- return { foreground: 0 };
125+ return { foreground: 0 }
126126 }
127- };
127+ }
128128
129129 if (props .readonly ) {
130130 watch (
@@ -147,6 +147,11 @@ onMounted(async () => {
147147 file .code
148148 )
149149 editorInstance .setModel (model )
150+
151+ if (file .selection ) {
152+ editorInstance .setSelection (file .selection )
153+ editorInstance .focus ()
154+ }
150155 },
151156 { immediate: true }
152157 )
@@ -161,6 +166,14 @@ onMounted(async () => {
161166 editorInstance .onDidChangeModelContent (() => {
162167 emits (' change' , editorInstance .getValue ())
163168 })
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+ })
164177})
165178
166179onBeforeUnmount (() => {
0 commit comments