Skip to content

Commit

Permalink
Merge pull request #2058 from xconverge/dispose-old-modehandlers
Browse files Browse the repository at this point in the history
Dispose modehandler if NO documents match the modehandler document anymore
  • Loading branch information
xconverge authored Oct 11, 2017
2 parents b42de22 + 9aa47b2 commit bee6ac6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,21 @@ export async function activate(context: vscode.ExtensionContext) {
});
});

vscode.workspace.onDidCloseTextDocument(event => {
const documents = vscode.workspace.textDocuments;

// Delete modehandler if vscode knows NOTHING about this document. This does
// not handle the case of the same file open twice. This only handles the
// case of deleting a modehandler once all tabs of this document have been
// closed
for (let mh in modeHandlerToEditorIdentity) {
const editor = modeHandlerToEditorIdentity[mh].vimState.editor.document;
if (documents.indexOf(editor) === -1) {
delete modeHandlerToEditorIdentity[mh];
}
}
});

registerCommand(context, 'toggleVim', async () => {
Globals.active = !Globals.active;
if (Globals.active) {
Expand Down

0 comments on commit bee6ac6

Please sign in to comment.