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

Add editorFileExtension when clause context #34889

Merged
merged 4 commits into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/vs/editor/common/editorContextKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export namespace EditorContextKeys {

// -- mode context keys
export const languageId = new RawContextKey<string>('editorLangId', undefined);
export const fileExtension = new RawContextKey<string>('editorFileExtension', undefined);
Copy link
Member

@jrieken jrieken Sep 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use File as it might not a file, maybe editorResourceExtension, editorExtension, or editorExtname?

export const hasCompletionItemProvider = new RawContextKey<boolean>('editorHasCompletionItemProvider', undefined);
export const hasCodeActionsProvider = new RawContextKey<boolean>('editorHasCodeActionsProvider', undefined);
export const hasCodeLensProvider = new RawContextKey<boolean>('editorHasCodeLensProvider', undefined);
Expand Down
4 changes: 4 additions & 0 deletions src/vs/editor/common/modes/editorModeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class EditorModeContext extends Disposable {
private _editor: ICommonCodeEditor;

private _langId: IContextKey<string>;
private _fileExtension: IContextKey<string>;
private _hasCompletionItemProvider: IContextKey<boolean>;
private _hasCodeActionsProvider: IContextKey<boolean>;
private _hasCodeLensProvider: IContextKey<boolean>;
Expand All @@ -40,6 +41,7 @@ export class EditorModeContext extends Disposable {
this._editor = editor;

this._langId = EditorContextKeys.languageId.bindTo(contextKeyService);
this._fileExtension = EditorContextKeys.fileExtension.bindTo(contextKeyService);
this._hasCompletionItemProvider = EditorContextKeys.hasCompletionItemProvider.bindTo(contextKeyService);
this._hasCodeActionsProvider = EditorContextKeys.hasCodeActionsProvider.bindTo(contextKeyService);
this._hasCodeLensProvider = EditorContextKeys.hasCodeLensProvider.bindTo(contextKeyService);
Expand Down Expand Up @@ -87,6 +89,7 @@ export class EditorModeContext extends Disposable {

reset() {
this._langId.reset();
this._fileExtension.reset();
this._hasCompletionItemProvider.reset();
this._hasCodeActionsProvider.reset();
this._hasCodeLensProvider.reset();
Expand All @@ -111,6 +114,7 @@ export class EditorModeContext extends Disposable {
return;
}
this._langId.set(model.getLanguageIdentifier().language);
this._fileExtension.set(model.uri.path.split('.').pop());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱 use paths.extname

this._hasCompletionItemProvider.set(modes.SuggestRegistry.has(model));
this._hasCodeActionsProvider.set(modes.CodeActionProviderRegistry.has(model));
this._hasCodeLensProvider.set(modes.CodeLensProviderRegistry.has(model));
Expand Down