Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
fix #32
Browse files Browse the repository at this point in the history
  • Loading branch information
74th committed May 14, 2016
1 parent 2d84d19 commit 46e1ef9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/VSCodeEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export class VSCodeEditor implements IEditor {
private visualLineModeEndLine: number;
private visualLineModeFocusPosition: IPosition;

private latestPosition: IPosition;
private latestPositionTimestamp: number;

public Options: IVSCodeEditorOptions;

public constructor(options: IVSCodeEditorOptions) {
Expand Down Expand Up @@ -106,13 +109,21 @@ export class VSCodeEditor implements IEditor {

// Position
public GetCurrentPosition(): IPosition {
if( this.latestPosition ){
let now = new Date().getTime();
if (now < this.latestPositionTimestamp + 400) {
return this.latestPosition;
}
}
return tranceVimStylePosition(vscode.window.activeTextEditor.selection.active);
}
public SetPosition(p: IPosition) {
let cp = tranceVSCodePosition(p);
vscode.window.activeTextEditor.selection = new vscode.Selection(cp, cp);
vscode.window.activeTextEditor.revealRange(vscode.window.activeTextEditor.selection, vscode.TextEditorRevealType.Default);
this.showBlockCursor();
this.latestPositionTimestamp = new Date().getTime();
this.latestPosition = p;
}
public GetLastPosition(): IPosition {
let end = vscode.window.activeTextEditor.document.lineAt(vscode.window.activeTextEditor.document.lineCount - 1).range.end;
Expand Down

0 comments on commit 46e1ef9

Please sign in to comment.