Vim: Wrong cursor position after using same file in two panels

Is this a BUG REPORT or FEATURE REQUEST? (choose one):

It’s a bug report

What happened:

  1. Open same file in two panels (i.e. side by side) with vim mode enabled
  2. At one buffer (A) jump to line 10
  3. At second buffer (B) click at line 20
  4. Get back to buffer A (at this point we are at line 10) and hit j (for vim “down by line” move)
  5. I am taken to line 21

What did you expect to happen:

At point 5 I should be taken to line 11.

How to reproduce it (as minimally and precisely as possible):

I’ve described it at the What happened section. Here is a video.

video

Environment:

  • Extension (VsCodeVim) version: 0.12.0
  • VSCode version: 1.23.1
  • OS version: 10.13.2 (17C88)

Update

Seems like reverting one change helped. I’ve created a PR.

For v0.14+ fix please see the comment

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 39
  • Comments: 19 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks @chibicode. For folks following this issue, please thumbs upstream vscode issue!

Seems this would be fixed in near future but it still breaks at 0.14. Here is a diff one can use to fix the issue (but note that this will bring back another issue with undo).

diff --git out/src/editorIdentity.js out/src/editorIdentity.js
index 2635d31..414b434 100644
--- out/src/editorIdentity.js
+++ out/src/editorIdentity.js
@@ -1,20 +1,26 @@
 "use strict";
+const vscode = require("vscode");
+
 Object.defineProperty(exports, "__esModule", { value: true });
 class EditorIdentity {
     constructor(textEditor) {
         this._fileName = (textEditor && textEditor.document && textEditor.document.fileName) || '';
+        this._viewColumn = (textEditor && textEditor.viewColumn) || vscode.ViewColumn.One;
     }
     get fileName() {
         return this._fileName;
     }
+    get viewColumn() {
+      return this._viewColumn;
+    }
     hasSameBuffer(identity) {
         return this.fileName === identity.fileName;
     }
     isEqual(other) {
-        return this.fileName === other.fileName;
+        return this.fileName === other.fileName && this.viewColumn === other.viewColumn;
     }
     toString() {
-        return this.fileName;
+        return this.fileName + this.viewColumn;
     }
 }
 exports.EditorIdentity = EditorIdentity;

you can apply it with patch -p0 < FILENAME at ~/.vscode/extensions/vscodevim.vim-0.14.0/


Updated patch for 0.16:

diff --git out/src/editorIdentity.js out/src/editorIdentity.js
index 2635d31..414b434 100644
--- out/src/editorIdentity.js
+++ out/src/editorIdentity.js
@@ -1,20 +1,26 @@
 "use strict";
+const vscode = require("vscode");
+
 Object.defineProperty(exports, "__esModule", { value: true });
 class EditorIdentity {
     constructor(textEditor) {
         this._fileName = (textEditor && textEditor.document && textEditor.document.fileName) || '';
+        this._viewColumn = (textEditor && textEditor.viewColumn) || vscode.ViewColumn.One;
     }
     get fileName() {
         return this._fileName;
     }
+    get viewColumn() {
+      return this._viewColumn;
+    }
     isEqual(other) {
-        return this.fileName === other.fileName;
+        return this.fileName === other.fileName && this.viewColumn === other.viewColumn;
     }
     toString() {
-        return this.fileName;
+        return this.fileName + this.viewColumn;
     }
 }
 exports.EditorIdentity = EditorIdentity;