mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-08-17 00:00:26 +03:00
Attempt to fix undo. Refs #8157.
The issue is pretty clearly that a recent VS Code update caused `onDidChangeTextDocument` events to be created (unreliably, from my testing) in such a way that trips our "change from disk" logic. We respond to that situation rather pessimistically by throwing out our undo stack, rather than trying to do something clever. I haven't had the time lately to dig into the nitty gritty details of what changed on VS Code's side, so this is a bit of a shot in the dark. The "change from disk" logic has caused issues in the past and I'm not sure how to reliably make it work, so I'm just deleting it for now. This may cause problems in some edge cases, but judging by my dogfooding, that'll be much less disruptive than losing your undo stack frequently enough that you can't trust it.
This commit is contained in:
parent
5210e120f3
commit
76f9723e5f
@ -16,7 +16,6 @@ import { globalState } from './src/state/globalState';
|
||||
import { taskQueue } from './src/taskQueue';
|
||||
import { Register } from './src/register/register';
|
||||
import { SpecialKeys } from './src/util/specialKeys';
|
||||
import { HistoryTracker } from './src/history/historyTracker';
|
||||
import { exCommandParser } from './src/vimscript/exCommandParser';
|
||||
|
||||
let extensionContext: vscode.ExtensionContext;
|
||||
@ -187,19 +186,6 @@ export async function activate(context: vscode.ExtensionContext, handleLocal: bo
|
||||
.forEach((modeHandler) => {
|
||||
contentChangeHandler(modeHandler);
|
||||
});
|
||||
|
||||
if (handleLocal) {
|
||||
setTimeout(() => {
|
||||
if (
|
||||
!event.document.isDirty &&
|
||||
!event.document.isUntitled &&
|
||||
event.document.uri.scheme !== 'vscode-notebook-cell' && // TODO: Notebooks never seem to be marked dirty...
|
||||
event.contentChanges.length
|
||||
) {
|
||||
handleContentChangedFromDisk(event.document);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
registerEventListener(
|
||||
@ -652,12 +638,3 @@ async function forceStopRecursiveRemap(mh: ModeHandler): Promise<boolean> {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function handleContentChangedFromDisk(document: vscode.TextDocument): void {
|
||||
Logger.info(`Resetting history for ${document.fileName} because content changed from disk`);
|
||||
ModeHandlerMap.getAll()
|
||||
.filter((modeHandler) => modeHandler.vimState.documentUri === document.uri)
|
||||
.forEach((modeHandler) => {
|
||||
modeHandler.vimState.historyTracker = new HistoryTracker(modeHandler.vimState);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user