File tree Expand file tree Collapse file tree 3 files changed +41
-3
lines changed
src/routes/tutorial/[slug] Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Original file line number Diff line number Diff line change 40
40
"@codemirror/lang-javascript" : " ^6.1.4" ,
41
41
"@codemirror/language" : " ^6.6.0" ,
42
42
"@codemirror/lint" : " ^6.2.0" ,
43
+ "@codemirror/search" : " ^6.3.0" ,
43
44
"@codemirror/state" : " ^6.2.0" ,
44
45
"@codemirror/view" : " ^6.9.2" ,
45
46
"@fontsource/roboto-mono" : " ^4.5.10" ,
48
49
"@lezer/javascript" : " ^1.4.1" ,
49
50
"@lezer/lr" : " ^1.3.3" ,
50
51
"@replit/codemirror-lang-svelte" : " ^6.0.0" ,
52
+ "@replit/codemirror-vim" : " ^6.0.9" ,
51
53
"@rich_harris/svelte-split-pane" : " ^1.1.0" ,
52
54
"@webcontainer/api" : " ^1.1.0" ,
53
55
"adm-zip" : " ^0.5.10" ,
Original file line number Diff line number Diff line change 78
78
}
79
79
}
80
80
81
+ let installed_vim = false ;
82
+
81
83
/** @param {import('$lib/types').Stub[]} $files */
82
- function reset ($files ) {
84
+ async function reset ($files ) {
83
85
if (skip_reset) return ;
84
86
87
+ let should_install_vim = localStorage .getItem (' vim' ) === ' true' ;
88
+
89
+ const q = new URLSearchParams (location .search );
90
+ if (q .has (' vim' )) {
91
+ should_install_vim = q .get (' vim' ) === ' true' ;
92
+ localStorage .setItem (' vim' , should_install_vim .toString ());
93
+ }
94
+
95
+ if (! installed_vim && should_install_vim) {
96
+ installed_vim = true ;
97
+ const { vim } = await import (' @replit/codemirror-vim' );
98
+ extensions .push (vim ());
99
+ }
100
+
85
101
for (const file of $files) {
86
102
if (file .type !== ' file' ) continue ;
87
103
174
190
skip_reset = true ;
175
191
});
176
192
177
- afterNavigate (() => {
193
+ afterNavigate (async () => {
178
194
skip_reset = false ;
179
195
180
196
editor_states .clear ();
181
- reset ($files);
197
+ await reset ($files);
182
198
183
199
if (editor_view) {
184
200
// could be false if onMount returned early
You can’t perform that action at this time.
0 commit comments