Skip to content

Commit

Permalink
refactor: remove lastClickWasPastEol from vim state
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoon committed Feb 19, 2018
1 parent b88c38d commit a2023fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
9 changes: 3 additions & 6 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,15 @@ export class ModeHandler implements vscode.Disposable {
}

let toDraw = false;
let isLastClickPastEol = false;

if (selection) {
let newPosition = new Position(selection.active.line, selection.active.character);

// Only check on a click, not a full selection (to prevent clicking past EOL)
if (newPosition.character >= newPosition.getLineEnd().character && selection.isEmpty) {
if (this.vimState.currentMode !== ModeName.Insert) {
this.vimState.lastClickWasPastEol = true;
isLastClickPastEol = true;

// This prevents you from mouse clicking past the EOL
newPosition = new Position(
Expand All @@ -201,16 +202,13 @@ export class ModeHandler implements vscode.Disposable {

toDraw = true;
}
} else if (selection.isEmpty) {
this.vimState.lastClickWasPastEol = false;
}

this.vimState.cursorPosition = newPosition;
this.vimState.cursorStartPosition = newPosition;
this.vimState.desiredColumn = newPosition.character;

// start visual mode?

if (
selection.anchor.line === selection.active.line &&
selection.anchor.character >= newPosition.getLineEnd().character - 1 &&
Expand All @@ -231,11 +229,10 @@ export class ModeHandler implements vscode.Disposable {
}

// If we prevented from clicking past eol but it is part of this selection, include the last char
if (this.vimState.lastClickWasPastEol) {
if (isLastClickPastEol) {
const newStart = new Position(selection.anchor.line, selection.anchor.character + 1);
this.vimState.editor.selection = new vscode.Selection(newStart, selection.end);
this.vimState.cursorStartPosition = selectionStart;
this.vimState.lastClickWasPastEol = false;
}

if (
Expand Down
5 changes: 0 additions & 5 deletions src/state/vimState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,6 @@ export class VimState implements vscode.Disposable {
public lastVisualSelectionStart: Position;
public lastVisualSelectionEnd: Position;

/**
* Was the previous mouse click past EOL
*/
public lastClickWasPastEol: boolean = false;

/**
* The mode Vim will be in once this action finishes.
*/
Expand Down

0 comments on commit a2023fd

Please sign in to comment.