Skip to content

Commit 8c3ce6b

Browse files
committed
Fix VSCode snippets
The lifecycle services weren't triggered anymore, I put them back now. Fixes codesandbox#3754 codesandbox#3110
1 parent 5ccffbd commit 8c3ce6b

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

packages/app/src/app/overmind/effects/vscode/index.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
initializeExtensionsFolder,
3838
initializeSettings,
3939
initializeThemeCache,
40+
initializeSnippetDirectory,
4041
} from './initializers';
4142
import { Linter } from './Linter';
4243
import {
@@ -190,6 +191,8 @@ export class VSCodeEffect {
190191
initializeCustomTheme();
191192
initializeThemeCache();
192193
initializeSettings();
194+
initializeSnippetDirectory();
195+
193196
this.setVimExtensionEnabled(
194197
localStorage.getItem('settings.vimmode') === 'true'
195198
);
@@ -665,16 +668,13 @@ export class VSCodeEffect {
665668
if (!activeEditor) {
666669
return;
667670
}
668-
671+
669672
const model = activeEditor.getModel();
670673
if (!model) {
671674
return;
672675
}
673-
674-
const headPos = indexToLineAndColumn(
675-
model.getLinesContent() || [],
676-
head
677-
);
676+
677+
const headPos = indexToLineAndColumn(model.getLinesContent() || [], head);
678678
const anchorPos = indexToLineAndColumn(
679679
model.getLinesContent() || [],
680680
anchor
@@ -841,7 +841,7 @@ export class VSCodeEffect {
841841
{ IEditorService },
842842
{ ICodeEditorService },
843843
{ ITextFileService },
844-
844+
{ ILifecycleService },
845845
{ IEditorGroupsService },
846846
{ IStatusbarService },
847847
{ IExtensionService },
@@ -857,6 +857,7 @@ export class VSCodeEffect {
857857
r('vs/workbench/services/editor/common/editorService'),
858858
r('vs/editor/browser/services/codeEditorService'),
859859
r('vs/workbench/services/textfile/common/textfiles'),
860+
r('vs/platform/lifecycle/common/lifecycle'),
860861
r('vs/workbench/services/editor/common/editorGroupsService'),
861862
r('vs/platform/statusbar/common/statusbar'),
862863
r('vs/workbench/services/extensions/common/extensions'),
@@ -961,6 +962,15 @@ export class VSCodeEffect {
961962
if (this.settings.lintEnabled) {
962963
this.createLinter();
963964
}
965+
966+
const lifecycleService = accessor.get(ILifecycleService);
967+
968+
// Trigger all VSCode lifecycle listeners
969+
lifecycleService.phase = 2; // Restoring
970+
requestAnimationFrame(() => {
971+
lifecycleService.phase = 3; // Running
972+
});
973+
964974
resolve();
965975
});
966976
});

packages/app/src/app/overmind/effects/vscode/initializers.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,13 @@ export function initializeCustomTheme() {
177177
installCustomTheme('custom', 'Custom Theme', customTheme);
178178
}
179179
}
180+
181+
export function initializeSnippetDirectory() {
182+
const fs = window.BrowserFS.BFSRequire('fs');
183+
184+
const folder = `/vscode/snippets`;
185+
const folderExists = fs.existsSync(folder);
186+
if (!folderExists) {
187+
fs.mkdirSync(folder);
188+
}
189+
}

0 commit comments

Comments
 (0)