Skip to content

Commit 31a5fb2

Browse files
authored
Route emmet actions to extension (microsoft#25587)
* Route emmet actions to extension * No need for settings
1 parent 2225ab4 commit 31a5fb2

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/vs/workbench/parts/emmet/node/emmetActions.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import * as pfs from 'vs/base/node/pfs';
2323
import Severity from 'vs/base/common/severity';
2424
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
2525
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
26+
import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/commands';
2627

2728
interface IEmmetConfiguration {
2829
emmet: {
@@ -235,6 +236,14 @@ export interface IEmmetActionOptions extends IActionOptions {
235236

236237
export abstract class EmmetEditorAction extends EditorAction {
237238

239+
private actionMap = {
240+
'editor.emmet.action.removeTag': 'emmet.removeTag',
241+
'editor.emmet.action.updateTag': 'emmet.updateTag',
242+
'editor.emmet.action.matchingPair': 'emmet.matchTag',
243+
'editor.emmet.action.wrapWithAbbreviation': 'emmet.wrapWithAbbreviation',
244+
'editor.emmet.action.expandAbbreviation': 'emmet.expandAbbreviation'
245+
};
246+
238247
protected emmetActionName: string;
239248

240249
constructor(opts: IEmmetActionOptions) {
@@ -269,6 +278,12 @@ export abstract class EmmetEditorAction extends EditorAction {
269278
const contextService = accessor.get(IWorkspaceContextService);
270279
const workspaceRoot = contextService.getWorkspace() ? contextService.getWorkspace().resource.fsPath : '';
271280
const telemetryService = accessor.get(ITelemetryService);
281+
const commandService = accessor.get(ICommandService);
282+
283+
let mappedCommand = this.actionMap[this.id];
284+
if (mappedCommand && CommandsRegistry.getCommand(mappedCommand)) {
285+
return commandService.executeCommand<void>(mappedCommand);
286+
}
272287

273288
return this._withGrammarContributions(extensionService).then((grammarContributions) => {
274289

@@ -296,7 +311,6 @@ export abstract class EmmetEditorAction extends EditorAction {
296311
this.runEmmetAction(accessor, new EmmetActionContext(editor, _emmet, editorAccessor));
297312
});
298313
editorAccessor.onAfterEmmetAction();
299-
telemetryService.publicLog('emmetActionCompleted', { action: this.emmetActionName });
300314
});
301315
});
302316

0 commit comments

Comments
 (0)