Skip to content

Commit 3bb0fda

Browse files
committed
Disallow auto closing tags for live
Fixes codesandbox#3398
1 parent 3118c21 commit 3bb0fda

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ export function initializeSettings() {
4343
)
4444
);
4545
}
46+
47+
try {
48+
// We need to do this to prevent duplicate closing tags in live sessions.
49+
// https://github.com/codesandbox/codesandbox-client/issues/3398
50+
// I haven't found another way to fix this, as the TS extension literally listens
51+
// for edits and checks whether an edit ends with '>'. Then it asks the LSP for the changes
52+
// and applies them 100ms later. There is no check for cursor or anything else.
53+
// This doesn't happen in VSCode Live Share itself, because there they share the LSP between
54+
// multiple users. This way the request is not duplicated among multiple users.
55+
const settings = JSON.parse(
56+
fs.readFileSync('/vscode/settings.json').toString()
57+
);
58+
settings['javascript.autoClosingTags'] = false;
59+
settings['typescript.autoClosingTags'] = false;
60+
fs.writeFileSync(
61+
'/vscode/settings.json',
62+
JSON.stringify(settings, null, 2)
63+
);
64+
} catch (e) {
65+
console.warn(e);
66+
}
4667
}
4768

4869
export function initializeCodeSandboxTheme() {

0 commit comments

Comments
 (0)