From 4d905bd0723aaaf31b22f7188be3a1512b23773d Mon Sep 17 00:00:00 2001 From: Grant Mathews Date: Thu, 1 Dec 2016 15:33:38 -0500 Subject: [PATCH 1/6] Put snarky comment in README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f421a8a51..e2c0f0d05 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ The following is a subset of the supported configurations; the full list is desc #### startInInsertMode * Have VSCodeVim start in Insert Mode rather than Normal Mode. + * We would be remiss in our duties as Vim users not to say that you should really be staying in Normal mode as much as you can, but hey, who are we to stop you? #### useCtrlKeys * Enable Vim ctrl keys overriding common VS Code operations (eg. copy, paste, find, etc). Setting this option to true will enable: From 78bb04cf5341b60cd9fbaf3f7a8a808ec6e82708 Mon Sep 17 00:00:00 2001 From: Grant Mathews Date: Thu, 1 Dec 2016 15:35:07 -0500 Subject: [PATCH 2/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e2c0f0d05..d0701fd50 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Ask us questions, talk about contributing, or just say hi on [Slack](https://vsc ## Supported Options -The following is a subset of the supported configurations; the full list is described in [package.json](https://github.com/VSCodeVim/Vim/blob/master/package.json#L175): +The following is a subset of the supported configurations; the full list is described in the `Contributions` tab for this extension, or in our [package.json](https://github.com/VSCodeVim/Vim/blob/master/package.json#L175): #### insertModeKeyBindings/otherModesKeyBindings * Keybinding overrides to use for insert and other (non-insert) modes From 3c536195cee78969381d8a91f506d8de92472f5b Mon Sep 17 00:00:00 2001 From: johnfn Date: Fri, 2 Dec 2016 13:12:25 -0500 Subject: [PATCH 3/6] Fix #582. --- src/state/searchState.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/state/searchState.ts b/src/state/searchState.ts index 0f2b89caa..c75c2b449 100644 --- a/src/state/searchState.ts +++ b/src/state/searchState.ts @@ -1,4 +1,5 @@ import * as vscode from 'vscode'; +import * as _ from 'lodash'; import { Position } from './../motion/position'; import { TextEditor } from './../textEditor'; import { Configuration } from '../../src/configuration/configuration'; @@ -29,7 +30,7 @@ export class SearchState { return this._searchCursorStartPosition; } - private _matchesDocVersion: number; + private _cachedDocumentVersion: number; private _searchDirection: SearchDirection = SearchDirection.Forward; private isRegex: boolean; @@ -47,12 +48,14 @@ export class SearchState { private _recalculateSearchRanges({ forceRecalc }: { forceRecalc?: boolean } = {}): void { const search = this.searchString; + const selection = vscode.window.activeTextEditor.selection; + const lineToStartAt = Math.min(selection.start.line, selection.end.line); if (search === "") { return; } - if (this._matchesDocVersion !== TextEditor.getDocumentVersion() || forceRecalc) { + if (this._cachedDocumentVersion !== TextEditor.getDocumentVersion() || forceRecalc) { // Calculate and store all matching ranges - this._matchesDocVersion = TextEditor.getDocumentVersion(); + this._cachedDocumentVersion = TextEditor.getDocumentVersion(); this._matchRanges = []; /* @@ -83,8 +86,12 @@ export class SearchState { regex = new RegExp(searchRE, regexFlags); } + // Start at the current line and wrap the document if we hit the end. outer: - for (let lineIdx = 0; lineIdx < TextEditor.getLineCount(); lineIdx++) { + for (let lineIdx = lineToStartAt; + lineIdx !== lineToStartAt - 1; + lineIdx === TextEditor.getLineCount() - 1 ? lineIdx = 0 : lineIdx++) { + const line = TextEditor.getLineAt(new Position(lineIdx, 0)).text; let result = regex.exec(line); @@ -105,6 +112,10 @@ export class SearchState { result = regex.exec(line); } } + + this._matchRanges.sort((x, y) => + x.start.line < y.start.line || + x.start.line === y.start.line && x.start.character < y.start.character ? -1 : 1); } } @@ -113,7 +124,7 @@ export class SearchState { * * Pass in -1 as direction to reverse the direction we search. */ - public getNextSearchMatchPosition(startPosition: Position, direction = 1): { pos: Position, match: boolean} { + public getNextSearchMatchPosition(startPosition: Position, direction = 1): { pos: Position, match: boolean } { this._recalculateSearchRanges(); if (this._matchRanges.length === 0) { From 3e3e7f13dca8e6598d200f49eec872add3771e53 Mon Sep 17 00:00:00 2001 From: rebornix Date: Fri, 2 Dec 2016 15:09:54 -0800 Subject: [PATCH 4/6] remove used import --- src/state/searchState.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/state/searchState.ts b/src/state/searchState.ts index c75c2b449..564d539c1 100644 --- a/src/state/searchState.ts +++ b/src/state/searchState.ts @@ -1,5 +1,4 @@ import * as vscode from 'vscode'; -import * as _ from 'lodash'; import { Position } from './../motion/position'; import { TextEditor } from './../textEditor'; import { Configuration } from '../../src/configuration/configuration'; From 3bfacf1b11996a80da944bab22f863d28e1f8466 Mon Sep 17 00:00:00 2001 From: rebornix Date: Fri, 2 Dec 2016 15:10:18 -0800 Subject: [PATCH 5/6] bump package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8ad9a0c84..cfef12559 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Vim", "description": "Vim emulation for Visual Studio Code", "icon": "images/icon.png", - "version": "0.4.4", + "version": "0.4.5", "publisher": "vscodevim", "galleryBanner": { "color": "#e3f4ff", From 7dd706aea52a04211ca6423c864b4ef1366e93ee Mon Sep 17 00:00:00 2001 From: johnfn Date: Fri, 2 Dec 2016 20:23:57 -0500 Subject: [PATCH 6/6] Fix a search infinite loop. --- src/state/searchState.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/state/searchState.ts b/src/state/searchState.ts index 564d539c1..5a79dc806 100644 --- a/src/state/searchState.ts +++ b/src/state/searchState.ts @@ -85,12 +85,11 @@ export class SearchState { regex = new RegExp(searchRE, regexFlags); } + let lineIdx = lineToStartAt; + // Start at the current line and wrap the document if we hit the end. outer: - for (let lineIdx = lineToStartAt; - lineIdx !== lineToStartAt - 1; - lineIdx === TextEditor.getLineCount() - 1 ? lineIdx = 0 : lineIdx++) { - + do { const line = TextEditor.getLineAt(new Position(lineIdx, 0)).text; let result = regex.exec(line); @@ -110,7 +109,9 @@ export class SearchState { result = regex.exec(line); } - } + + lineIdx === TextEditor.getLineCount() - 1 ? lineIdx = 0 : lineIdx++; + } while (lineIdx !== lineToStartAt); this._matchRanges.sort((x, y) => x.start.line < y.start.line ||