-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clear history when content from disk is changed #703
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
import * as vscode from 'vscode'; | ||
import * as util from './src/util'; | ||
import * as _ from "lodash"; | ||
import { showCmdLine } from './src/cmd_line/main'; | ||
import { ModeHandler } from './src/mode/modeHandler'; | ||
import { TaskQueue } from './src/taskQueue'; | ||
|
@@ -114,6 +115,15 @@ export async function activate(context: vscode.ExtensionContext) { | |
|
||
vscode.window.onDidChangeActiveTextEditor(handleActiveEditorChange, this); | ||
|
||
vscode.workspace.onDidChangeTextDocument((event) => { | ||
/* TODO: Remove setTimeout (https://github.com/Microsoft/vscode/issues/11339) */ | ||
setTimeout(() => { | ||
if (event.document.isDirty === false) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose you are typing too fast to check a boolean through |
||
handleContentChangedFromDisk(event.document); | ||
} | ||
}, 0); | ||
}); | ||
|
||
registerCommand(context, 'type', async (args) => { | ||
if (!vscode.window.activeTextEditor) { | ||
return; | ||
|
@@ -217,6 +227,13 @@ async function handleKeyEvent(key: string): Promise<void> { | |
}); | ||
} | ||
|
||
function handleContentChangedFromDisk(document : vscode.TextDocument) : void { | ||
_.filter(modeHandlerToEditorIdentity, { "fileName" : document.fileName}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep the leading/trailing spaces consistent |
||
.forEach((modeHandler) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing about the brackets here :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about them? @jpoon There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That you can remove the brackets around There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@jpoon I saw other places are always using brackets even for a single argument, that's why i added those brackets 😄
|
||
modeHandler.vimState.historyTracker.clear(); | ||
}); | ||
} | ||
|
||
async function handleActiveEditorChange(): Promise<void> { | ||
|
||
// Don't run this event handler during testing | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write a little documentation on why this is needed (isDirty not immediately set etc)