提交 6110660a 编写于 作者: J Johannes Rieken

add 'resourceFilename' context key

上级 ef69c1db
......@@ -5,18 +5,20 @@
'use strict';
import URI from 'vs/base/common/uri';
import {basename} from 'vs/base/common/paths';
import {RawContextKey, IContextKeyService, IContextKey} from 'vs/platform/contextkey/common/contextkey';
import {IModeService} from 'vs/editor/common/services/modeService';
export class ResourceContextKey implements IContextKey<URI> {
static Scheme = new RawContextKey<string>('resourceScheme', undefined);
static Filename = new RawContextKey<string>('resourceFilename', undefined);
static LangId = new RawContextKey<string>('resourceLangId', undefined);
static Resource = new RawContextKey<URI>('resource', undefined);
private _resourceKey: IContextKey<URI>;
private _schemeKey: IContextKey<string>;
private _filenameKey: IContextKey<string>;
private _langIdKey: IContextKey<string>;
constructor(
......@@ -24,6 +26,7 @@ export class ResourceContextKey implements IContextKey<URI> {
@IModeService private _modeService: IModeService
) {
this._schemeKey = ResourceContextKey.Scheme.bindTo(contextKeyService);
this._filenameKey = ResourceContextKey.Filename.bindTo(contextKeyService);
this._langIdKey = ResourceContextKey.LangId.bindTo(contextKeyService);
this._resourceKey = ResourceContextKey.Resource.bindTo(contextKeyService);
}
......@@ -31,6 +34,7 @@ export class ResourceContextKey implements IContextKey<URI> {
set(value: URI) {
this._resourceKey.set(value);
this._schemeKey.set(value && value.scheme);
this._filenameKey.set(value && basename(value.fsPath));
this._langIdKey.set(value && this._modeService.getModeIdByFilenameOrFirstLine(value.fsPath));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册