Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/vs/editor/common/cursor/cursorTypeEditOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,23 @@ export class AutoClosingOpenCharTypeOperation {
if (!pair.shouldAutoClose(scopedLineTokens, beforeColumn - scopedLineTokens.firstCharOffset)) {
return null;
}
// If the cursor is inside an embedded language region (e.g. LaTeX
// embedded inside a markdown `$...$` math block), honor the
// embedded language's auto-closing pair configuration. Without
// this, the outer language's pairs (e.g. markdown's `<>`) would
// leak into regions where they are not meaningful.
// See https://github.com/microsoft/vscode/issues/272922 and the
// parent issue https://github.com/microsoft/vscode/issues/133397.
if (scopedLineTokens.languageId !== config.languageId) {
const embeddedConfig = config.languageConfigurationService.getLanguageConfiguration(scopedLineTokens.languageId);
const embeddedCandidates = embeddedConfig.getAutoClosingPairs().autoClosingPairsOpenByEnd.get(ch);
const hasMatchingEmbeddedPair = embeddedCandidates
? embeddedCandidates.some(c => c.open === pair.open && c.close === pair.close)
: false;
if (!hasMatchingEmbeddedPair) {
return null;
}
}
// Typing for example a quote could either start a new string, in which case auto-closing is desirable
// or it could end a previously started string, in which case auto-closing is not desirable
//
Expand Down
4 changes: 4 additions & 0 deletions src/vs/editor/common/cursorCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export class CursorConfiguration {
private readonly _languageId: string;
private _electricChars: { [key: string]: boolean } | null;

public get languageId(): string {
return this._languageId;
}

public static shouldRecreate(e: ConfigurationChangedEvent): boolean {
return (
e.hasChanged(EditorOption.layoutInfo)
Expand Down