Skip to content

Commit

Permalink
Merge branch 'master' into c_a_further
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoon committed Mar 3, 2020
2 parents ca55711 + 1389d4d commit 3048793
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 19 deletions.
137 changes: 128 additions & 9 deletions CHANGELOG.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Vim",
"description": "Vim emulation for Visual Studio Code",
"icon": "images/icon.png",
"version": "1.12.4",
"version": "1.13.0",
"publisher": "vscodevim",
"galleryBanner": {
"color": "#e3f4ff",
Expand Down Expand Up @@ -974,7 +974,7 @@
"sinon": "9.0.0",
"ts-loader": "6.2.1",
"tslint": "5.20.1",
"typescript": "3.8.2",
"typescript": "3.8.3",
"vscode": "1.1.36"
}
}
2 changes: 1 addition & 1 deletion src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ abstract class CommandEditorScroll extends BaseCommand {
by: this.by,
value: timesToRepeat,
revealCursor: true,
select: [Mode.Visual, Mode.VisualBlock, Mode.VisualLine].includes(vimState.currentMode),
select: isVisualMode(vimState.currentMode),
},
});
return vimState;
Expand Down
17 changes: 17 additions & 0 deletions src/actions/commands/commandLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,23 @@ class CommandEscInSearchMode extends BaseCommand {
? prevSearchList[prevSearchList.length - 1]
: undefined;

if (vimState.firstVisibleLineBeforeSearch !== undefined) {
const offset =
vimState.editor.visibleRanges[0].start.line - vimState.firstVisibleLineBeforeSearch;
if (offset !== 0) {
vimState.postponedCodeViewChanges.push({
command: 'editorScroll',
args: {
to: offset > 0 ? 'up' : 'down',
by: 'line',
value: Math.abs(offset),
revealCursor: false,
select: false,
},
});
}
}

await vimState.setCurrentMode(searchState.previousMode);
vimState.statusBarCursorCharacterPos = 0;

Expand Down
5 changes: 3 additions & 2 deletions src/common/motion/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ export class Position extends vscode.Position {

private getFirstNonWhitespaceInParagraph(paragraphEnd: Position, inclusive: boolean): Position {
// If the cursor is at an empty line, it's the end of a paragraph and the begin of another paragraph
// Find the first non-whitepsace character.
// Find the first non-whitespace character.
if (TextEditor.getLineAt(new vscode.Position(this.line, 0)).text) {
return paragraphEnd;
} else {
Expand All @@ -1260,7 +1260,8 @@ export class Position extends vscode.Position {
}
}

throw new Error('This should never happen...');
// Only happens at end of document
return this;
}

private findHelper(
Expand Down
6 changes: 5 additions & 1 deletion src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,11 @@ export class ModeHandler implements vscode.Disposable {
}

// Scroll to position of cursor
if (vimState.editor.visibleRanges.length > 0) {
if (
vimState.editor.visibleRanges.length > 0 &&
vimState.postponedCodeViewChanges.filter(change => change.command === 'editorScroll')
.length === 0
) {
const visibleRange = vimState.editor.visibleRanges[0];
const centerViewportAroundCursor =
visibleRange.start.line - vimState.cursorStopPosition.line >= 15 ||
Expand Down
12 changes: 12 additions & 0 deletions src/state/vimState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Range } from './../common/motion/range';
import { RecordedState } from './recordedState';
import { RegisterMode } from './../register/register';
import { ReplaceState } from './../state/replaceState';
import { TextEditor } from '../textEditor';

/**
* The VimState class holds permanent state that carries over from action
Expand Down Expand Up @@ -89,6 +90,11 @@ export class VimState implements vscode.Disposable {
*/
public visualLineStartColumn: number | undefined = undefined;

/**
* The first line number that was visible when SearchInProgressMode began (undefined if not searching)
*/
public firstVisibleLineBeforeSearch: number | undefined = undefined;

public focusChanged = false;

public surround:
Expand Down Expand Up @@ -224,6 +230,12 @@ export class VimState implements vscode.Disposable {
if (mode !== Mode.VisualLine) {
this.visualLineStartColumn = undefined;
}

if (mode === Mode.SearchInProgressMode) {
this.firstVisibleLineBeforeSearch = this.editor.visibleRanges[0].start.line;
} else {
this.firstVisibleLineBeforeSearch = undefined;
}
}

public currentRegisterMode = RegisterMode.AscertainFromCurrentMode;
Expand Down

0 comments on commit 3048793

Please sign in to comment.