Change:
With Vim keybinding extensions, there is a command :q! that is a force quit. When you execute this command it quits, without prompting, and without storing any changes. This is what differentiates it from hotexit, all changes should be reverted. All prompts should be suppressed and the editor should be closed right away. Currently there is nothing in the API to allow us to do this Over at VSCodeVim this is one of our highest rated issues:
thanks for the comments on the other ticket!
This sounds like a good issue to work on via PR
It was a trap!
If no one is on this yet, I'll try to look into this issue
I have roughly implemented force quit and an API linked to it. Since i'm not really sure if this is the right way to do it, it would be nice to get some comments about the PR.
After implementing, I realized it might be better to add the revert() function into and directly call the revert function from newly implemented Any thoughts?
I think you can do everything with the current API without introducing a lot more. You can use the from your action to access the model () which holds any editor that is open. You can iterate over the groups and editors and call on the ones which are dirty. After that is done you can close the editors. Btw is it really that should close all editors? Maybe this should keep the editors open but just revert all?
It seems like the function is only implemented in the and not declared in . That is why i asked if declaring the function into the interface was a good idea so that it could be invoked in my action as you proposed. As for the command, it is to my understanding that it should only close the activeEditor, therefore there is no need to iterate over all editors that are open. Did i understand it right?
yeah the interface doesn't mean a lot, so try to add it there but watch for compile errors.
I tried to use the in my action as you said, and spent more time looking deeply into the code base. After understanding more of the code, it feels like the code change in my current PR is more suitable to implement the command. It would be nice if you could briefly review my codes and comment on the changed lines if you still think is a better way. Thanks in advance! :)
I would first collect the actual requirements of what q! should do before going on. Does it close all files or the active file? Does it only revert? Does it quit?
q! only reverts and quits the active editor
what does "active editor" mean when you have multiple editors open. Does it literally reverts and close the currently active tab in the tab UI or revert all tabs and close the window?
Yes the tab, if a user does "qa!" Then we will use this command and iterate over the tabs from our side
thanks, looks like we need 2 new commands then. I still think using the editor group API to get the current active editor or all editors and then calling revert is a better approach. The API is all there so we should not arbitrarily introduce new API.
Why do you need 2 new commands? We will use the "force close tab" command and then loop over all tabs and execute the same command 2 commands would be fine though, just no guarantees we would use the "close all tabs of editor" command
After carefully reading the comments, I have newly implemented the command "". As for "force closing all tabs", I wasn't sure if it should be implemented or not.
There is now a that keybinding can be associated with.
What a hero

Discussion:
isDirty(): boolean; /** <ins> * Reverts this input. */ revert(): TPromise<boolean>; /** </ins> * Returns if the other object matches this input. */ matches(other: any): boolean;

} } <ins> export class RevertAndCloseEditorAction extends Action { public static ID = 'workbench.action.revertAndCloseActiveEditor'; public static LABEL = nls.localize('revertAndCloseActiveEditor', "Revert and Close Editor"); constructor( id: string, label: string, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, ) { super(id, label); } public run(): TPromise<any> { const activeEditor = this.editorService.getActiveEditor(); if (activeEditor) { return activeEditor.input.revert().then(ok => this.editorService.closeEditor(activeEditor.position, activeEditor.input) ); } return TPromise.as(false); } } </ins> export class CloseLeftEditorsInGroupAction extends Action { public static ID = 'workbench.action.closeEditorsToTheLeft';

import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes'; import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform'; import { CloseEditorAction, KeybindingsReferenceAction, OpenDocumentationUrlAction, OpenIntroductoryVideosUrlAction, ReportIssueAction, ReportPerformanceIssueAction, ZoomResetAction, ZoomOutAction, ZoomInAction, ToggleFullScreenAction, ToggleMenuBarAction, CloseFolderAction, CloseWindowAction, SwitchWindow, NewWindowAction, CloseMessagesAction } from 'vs/workbench/electron-browser/actions'; <ins> import { RevertAndCloseEditorAction } from 'vs/workbench/browser/parts/editor/editorActions'; </ins> import { MessagesVisibleContext } from 'vs/workbench/electron-browser/workbench'; import { IJSONSchema } from 'vs/base/common/jsonSchema'; import { registerCommands } from 'vs/workbench/electron-browser/commands';

); workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseMessagesAction, CloseMessagesAction.ID, CloseMessagesAction.LABEL, { primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape] }, MessagesVisibleContext), 'Close Notification Messages'); workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseEditorAction, CloseEditorAction.ID, CloseEditorAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_W, win: { primary: KeyMod.CtrlCmd | KeyCode.F4, secondary: [KeyMod.CtrlCmd | KeyCode.KEY_W] } }), 'View: Close Editor', viewCategory); <ins> workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(RevertAndCloseEditorAction, RevertAndCloseEditorAction.ID, RevertAndCloseEditorAction.LABEL, undefined), 'View: Revert and Close Editor', viewCategory); </ins> workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleFullScreenAction, ToggleFullScreenAction.ID, ToggleFullScreenAction.LABEL, { primary: KeyCode.F11, mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.KEY_F } }), 'View: Toggle Full Screen', viewCategory); if (isWindows || isLinux) { workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleMenuBarAction, ToggleMenuBarAction.ID, ToggleMenuBarAction.LABEL), 'View: Toggle Menu Bar', viewCategory);