Implement getProfileName for emmet (#19109)

This commit is contained in:
Ramya Rao 2017-01-25 10:21:16 -08:00 committed by GitHub
parent 63414263ac
commit eec1b5b107

View file

@ -143,6 +143,10 @@ export class EditorAccessor implements emmet.Editor {
}
public getSyntax(): string {
return this.getSyntaxInternal(true);
}
public getSyntaxInternal(overrideUsingProfiles: boolean): string {
let position = this._editor.getSelection().getStartPosition();
let languageId = this._editor.getModel().getLanguageIdAtPosition(position.lineNumber, position.column);
let language = this._languageIdentifierResolver.getLanguageIdentifier(languageId).language;
@ -154,7 +158,7 @@ export class EditorAccessor implements emmet.Editor {
// user can overwrite the syntax using the emmet syntaxProfiles setting
let profile = this.getSyntaxProfile(syntax);
if (profile && this.emmetSupportedModes.indexOf(profile) !== -1) {
if (overrideUsingProfiles && profile && this.emmetSupportedModes.indexOf(profile) !== -1) {
return profile;
}
@ -198,7 +202,16 @@ export class EditorAccessor implements emmet.Editor {
return syntax;
}
// If users have created their own output profile for current syntax as described
// http://docs.emmet.io/customization/syntax-profiles/#create-your-own-profile
// then we return the name of this profile. Else, we send null and
// emmet is smart enough to guess the right output profile
public getProfileName(): string {
let syntax = this.getSyntaxInternal(false);
const profile = this._syntaxProfiles[syntax];
if (profile && typeof profile !== 'string') {
return syntax;
}
return null;
}