Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #213141 #214456

Merged
merged 1 commit into from
Jun 6, 2024
Merged
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
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
Loading