-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Changes from 3 commits
bcf9df5
c5d19f5
e2f198e
0f4fdb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,13 @@ export class ResourceContextKey implements IContextKey<URI> { | |
static Filename = new RawContextKey<string>('resourceFilename', undefined); | ||
static LangId = new RawContextKey<string>('resourceLangId', undefined); | ||
static Resource = new RawContextKey<URI>('resource', undefined); | ||
static Extension = new RawContextKey<string>('resourceExtension', undefined); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, I'd prefer |
||
|
||
private _resourceKey: IContextKey<URI>; | ||
private _schemeKey: IContextKey<string>; | ||
private _filenameKey: IContextKey<string>; | ||
private _langIdKey: IContextKey<string>; | ||
private _extensionKey: IContextKey<string>; | ||
|
||
constructor( | ||
@IContextKeyService contextKeyService: IContextKeyService, | ||
|
@@ -37,19 +39,22 @@ export class ResourceContextKey implements IContextKey<URI> { | |
this._filenameKey = ResourceContextKey.Filename.bindTo(contextKeyService); | ||
this._langIdKey = ResourceContextKey.LangId.bindTo(contextKeyService); | ||
this._resourceKey = ResourceContextKey.Resource.bindTo(contextKeyService); | ||
this._extensionKey = ResourceContextKey.Extension.bindTo(contextKeyService); | ||
} | ||
|
||
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)); | ||
this._extensionKey.set(value && paths.extname(value.fsPath)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Way to go but we to think if folks expect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think typical behavior is to return extension with the dot. At least that's what most standard libraries I know do - Node's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More interesting question is if users expects it to be normalized to lower case (i.e if "ABC.FSX" should return ".FSX" or just ".fsx") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good questions... I'd say we have it "as is". I can see how a "normalized" version can help but that applies to many values, e.g. filename |
||
} | ||
|
||
reset(): void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jrieken. an reason why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say that is bug cc @bpasero There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jrieken introduced by you via 6110660#diff-cb108a154667420fbda68f22a3d6d90c ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙉 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I add this missing reset in this PR? |
||
this._schemeKey.reset(); | ||
this._langIdKey.reset(); | ||
this._resourceKey.reset(); | ||
this._extensionKey.reset(); | ||
} | ||
|
||
public get(): URI { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a second look: we actually don't need to repeat this. Having
resourceExtname/Extension
is enough has it gets inherited to the editor from its column/slot. The reason for havingeditorLangId
andresourceLangId
is that latter is derived from the name while the former is more correct (look at the name and the contents)