Skip to content

Commit

Permalink
Fixes #213141
Browse files Browse the repository at this point in the history
  • Loading branch information
hediet committed Jun 6, 2024
1 parent 86f1484 commit 6efe1ab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Emitter } from 'vs/base/common/event';
import { Disposable, DisposableStore, IDisposable, IReference, MutableDisposable } from 'vs/base/common/lifecycle';
import { IPosition, Position } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
import { ILanguageConfigurationService, LanguageConfigurationServiceChangeEvent } from 'vs/editor/common/languages/languageConfigurationRegistry';
import { ignoreBracketsInToken } from 'vs/editor/common/languages/supports';
import { LanguageBracketsConfiguration } from 'vs/editor/common/languages/supports/languageBracketsConfiguration';
import { BracketsUtils, RichEditBracket, RichEditBrackets } from 'vs/editor/common/languages/supports/richEditBrackets';
Expand Down Expand Up @@ -36,19 +36,17 @@ export class BracketPairsTextModelPart extends Disposable implements IBracketPai
private readonly languageConfigurationService: ILanguageConfigurationService
) {
super();

this._register(
this.languageConfigurationService.onDidChange(e => {
if (!e.languageId || this.bracketPairsTree.value?.object.didLanguageChange(e.languageId)) {
this.bracketPairsTree.clear();
this.updateBracketPairsTree();
}
})
);
}

//#region TextModel events

public handleLanguageConfigurationServiceChange(e: LanguageConfigurationServiceChangeEvent): void {
if (!e.languageId || this.bracketPairsTree.value?.object.didLanguageChange(e.languageId)) {
this.bracketPairsTree.clear();
this.updateBracketPairsTree();
}
}

public handleDidChangeOptions(e: IModelOptionsChangedEvent): void {
this.bracketPairsTree.clear();
this.updateBracketPairsTree();
Expand Down
5 changes: 5 additions & 0 deletions src/vs/editor/common/model/textModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
}));

this._languageService.requestRichLanguageFeatures(languageId);

this._register(this._languageConfigurationService.onDidChange(e => {
this._bracketPairs.handleLanguageConfigurationServiceChange(e);
this._tokenizationTextModelPart.handleLanguageConfigurationServiceChange(e);
}));
}

public override dispose(): void {
Expand Down
14 changes: 7 additions & 7 deletions src/vs/editor/common/model/tokenizationTextModelPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { IWordAtPosition, getWordAtText } from 'vs/editor/common/core/wordHelper
import { StandardTokenType } from 'vs/editor/common/encodedTokenAttributes';
import { IBackgroundTokenizationStore, IBackgroundTokenizer, ILanguageIdCodec, IState, ITokenizationSupport, TokenizationRegistry } from 'vs/editor/common/languages';
import { ILanguageService } from 'vs/editor/common/languages/language';
import { ILanguageConfigurationService, ResolvedLanguageConfiguration } from 'vs/editor/common/languages/languageConfigurationRegistry';
import { ILanguageConfigurationService, LanguageConfigurationServiceChangeEvent, ResolvedLanguageConfiguration } from 'vs/editor/common/languages/languageConfigurationRegistry';
import { IAttachedView } from 'vs/editor/common/model';
import { BracketPairsTextModelPart } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsImpl';
import { AttachedViews, IAttachedViewState, TextModel } from 'vs/editor/common/model/textModel';
Expand Down Expand Up @@ -56,12 +56,6 @@ export class TokenizationTextModelPart extends TextModelPart implements ITokeniz
) {
super();

this._register(this._languageConfigurationService.onDidChange(e => {
if (e.affects(this._languageId)) {
this._onDidChangeLanguageConfiguration.fire({});
}
}));

this._register(this.grammarTokens.onDidChangeTokens(e => {
this._emitModelTokensChangedEvent(e);
}));
Expand All @@ -77,6 +71,12 @@ export class TokenizationTextModelPart extends TextModelPart implements ITokeniz
|| this._onDidChangeTokens.hasListeners());
}

public handleLanguageConfigurationServiceChange(e: LanguageConfigurationServiceChangeEvent): void {
if (e.affects(this._languageId)) {
this._onDidChangeLanguageConfiguration.fire({});
}
}

public handleDidChangeContent(e: IModelContentChangedEvent): void {
if (e.isFlush) {
this._semanticTokens.flush();
Expand Down

0 comments on commit 6efe1ab

Please sign in to comment.