Skip to content

Commit 791979c

Browse files
committed
Fix some VSCode bugs
1 parent b239e29 commit 791979c

File tree

2,500 files changed

+37
-859538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,500 files changed

+37
-859538
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ yarn-error.log
2424
jest
2525

2626
lerna-debug.log
27+
28+
standalone-packages/monaco-editor-core

packages/app/src/app/components/CodeEditor/Monaco/MonacoReactComponent.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class MonacoEditor extends React.PureComponent {
5353
openModel: model => this.props.openReference(model),
5454
};
5555

56-
let appliedOptions = { ...options };
56+
const appliedOptions = { ...options };
5757

5858
const fonts = appliedOptions.fontFamily.split(',').map(x => x.trim());
5959
// We first just set the default fonts for the editor. When the custom font has loaded
@@ -79,10 +79,6 @@ class MonacoEditor extends React.PureComponent {
7979

8080
appliedOptions.fontFamily = fonts.slice(1).join(', ');
8181

82-
if (localStorage.getItem('settings.experimentVSCode') === 'true') {
83-
appliedOptions = {};
84-
}
85-
8682
this.editor = context.monaco.editor[
8783
diffEditor ? 'createDiffEditor' : 'create'
8884
](this.containerElement, appliedOptions);

packages/app/src/app/components/CodeEditor/VSCode/MonacoReactComponent.js

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export type EditorAPI = {
1515
editorService: any,
1616
};
1717

18+
const fontPromise = new FontFaceObserver('dm').load().catch(() => {});
19+
1820
class MonacoEditor extends React.PureComponent {
1921
constructor(props) {
2022
super(props);
@@ -48,7 +50,7 @@ class MonacoEditor extends React.PureComponent {
4850
};
4951

5052
initMonaco = () => {
51-
const { theme, options, diffEditor = false } = this.props;
53+
const { theme, diffEditor = false } = this.props;
5254
const context = this.props.context || window;
5355
if (this.containerElement && typeof context.monaco !== 'undefined') {
5456
// Before initializing monaco editor
@@ -58,31 +60,6 @@ class MonacoEditor extends React.PureComponent {
5860
openModel: model => this.props.openReference(model),
5961
};
6062

61-
const appliedOptions = { ...options };
62-
63-
const fonts = appliedOptions.fontFamily.split(',').map(x => x.trim());
64-
// We first just set the default fonts for the editor. When the custom font has loaded
65-
// we set that one so that Monaco doesn't get confused.
66-
// https://github.com/Microsoft/monaco-editor/issues/392
67-
let firstFont = fonts[0];
68-
if (firstFont.startsWith('"')) {
69-
// Font is eg. '"aaaa"'
70-
firstFont = JSON.parse(firstFont);
71-
}
72-
const font = new FontFaceObserver(firstFont);
73-
74-
font.load().then(
75-
() => {
76-
if (this.editor && this.props.getEditorOptions) {
77-
this.editor.updateOptions(this.props.getEditorOptions());
78-
}
79-
},
80-
() => {
81-
// Font was not loaded in 3s, do nothing
82-
}
83-
);
84-
85-
appliedOptions.fontFamily = fonts.slice(1).join(', ');
8663
const r = context.require;
8764

8865
const [
@@ -112,7 +89,7 @@ class MonacoEditor extends React.PureComponent {
11289

11390
context.monaco.editor[diffEditor ? 'createDiffEditor' : 'create'](
11491
container,
115-
appliedOptions,
92+
{},
11693
{
11794
codesandboxService: i =>
11895
i.createInstance(CodeSandboxService, controller),
@@ -144,8 +121,10 @@ class MonacoEditor extends React.PureComponent {
144121

145122
const editorApi = {
146123
openFile(path: string) {
147-
return codeEditorService.openCodeEditor({
148-
resource: context.monaco.Uri.file('/sandbox' + path),
124+
fontPromise.then(() => {
125+
codeEditorService.openCodeEditor({
126+
resource: context.monaco.Uri.file('/sandbox' + path),
127+
});
149128
});
150129
},
151130
getActiveCodeEditor() {

packages/app/src/app/components/Preview/DevTools/Console/Input/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const monacoOptions = {
9696
},
9797
contextmenu: false,
9898
ariaLabel: 'ConsoleInput',
99-
fontFamily: 'Menlo, monospace',
99+
fontFamily: 'dm, Menlo, monospace',
100100
fontSize: 13,
101101
};
102102

packages/app/src/app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<!-- {{OEMBED TAG}} -->
4141
<title>CodeSandbox</title>
4242
<script src="https://cdn.ravenjs.com/3.21.0/raven.min.js" crossorigin="anonymous"></script>
43-
<link href="/static/fonts/dmvendor.css" rel="stylesheet">
43+
<link href="/static/fonts/dmvendor.css" rel="stylesheet"></link>
4444
<!-- Google Tag Manager -->
4545
<script>
4646
(function (w, d, s, l, i) {

standalone-packages/monaco-editor-core/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

standalone-packages/monaco-editor-core/README.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

standalone-packages/monaco-editor-core/ThirdPartyNotices.txt

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)