Skip to content
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

Readds vimState.lastClickWasPastEOL. Fixes #2404 #2433

Merged
merged 2 commits into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,14 @@ 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) {
isLastClickPastEol = true;
this.vimState.lastClickWasPastEol = true;

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

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

this.vimState.cursorPosition = newPosition;
Expand Down Expand Up @@ -229,10 +230,11 @@ 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 (isLastClickPastEol) {
if (this.vimState.lastClickWasPastEol) {
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
4 changes: 4 additions & 0 deletions src/state/vimState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ 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