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

Changing between editors quickly causes the cursor and scroll position to reset #40114

Closed
akbyrd opened this issue Dec 12, 2017 · 8 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded workbench-editors Managing of editor widgets in workbench window
Milestone

Comments

@akbyrd
Copy link
Contributor

akbyrd commented Dec 12, 2017

  • VSCode Version: Code - Insiders 1.19.0-insider (d8989c9, 2017-12-08T10:45:40.870Z)
  • OS Version: Windows_NT x64 10.0.15063
  • Extensions:
Extension Author (truncated) Version
tortoise-svn fan 0.1.1
output-colorizer IBM 0.1.2
Lua key 0.0.9
python ms- 0.8.0
cpptools ms- 0.14.4
code-settings-sync Sha 2.8.7
shader sle 1.1.2
slack soz 0.0.13
Align ste 0.2.0
vscode-todo-highlight way 0.5.11

(4 theme extensions excluded)


Issue:

Changing between editors quickly causes the cursor and scroll position to reset.

Steps to Reproduce:

  1. Open 2-3 files
  2. Move the cursor and scroll position to the bottom of each file
  3. Trigger workbench.action.nextEditorInGroup / previousEditorInGroup rapidly
  4. Notice the cursor and scroll position eventually end up back at the top of each file.
@vscodebot vscodebot bot added insiders editor-core Editor basic functionality labels Dec 12, 2017
@alexdima
Copy link
Member

I cannot reproduce:

kapture 2017-12-13 at 9 29 07

@alexdima alexdima added info-needed Issue requires more information from poster and removed editor-core Editor basic functionality labels Dec 13, 2017
@vscodebot vscodebot bot closed this as completed Dec 20, 2017
@vscodebot
Copy link

vscodebot bot commented Dec 20, 2017

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@akbyrd
Copy link
Contributor Author

akbyrd commented Dec 20, 2017

  • VSCode Version: Code 1.19.0 (816be67, 2017-12-14T12:06:43.492Z)
  • OS Version: Windows_NT x64 10.0.16299
  • Extensions: none

I just repro'd this with the latest stable version, no extensions, everything at stock defaults. You have to hit the keybindings very quickly. Maybe some sort of race condition.

The cursor doesn't always move to the beginning of the file, sometimes it moves somewhere in the middle. I think it's related to where the cursor is in the other editor.

My easiest repro is:

  1. Open 2 editors, one less than a full page (doesn't scroll), one more than a full page (scrolls).
  2. Move the cursor in each editor to the end of the file.
  3. Jump back and forth as fast as you can.
  4. Notice the cursor in the longer file moves to the line number matching the last line of the shorter file, and/or
  5. Notice the cursor in the shorter file stays in the correct place, but the contents are scroll out of view.

vs code cusor bug

In the GIF above the first file is 33 lines and the second is 183 lines. The cursor starts at the bottom of each. After jumping between editors a few times you see the cursor in the second file is suddenly at line 33, not line 183 where it started.

@akbyrd
Copy link
Contributor Author

akbyrd commented Dec 22, 2017

@alexandrudima Do I need to create a new issue for this or can it be reopened?

@alexdima
Copy link
Member

alexdima commented Jan 8, 2018

Thank you @akbyrd . I have been able to reproduce locally. It is indeed some form of race condition.


@bpasero I've added the following keybindings:

    {
        "key": "ctrl+alt+right",
        "command": "workbench.action.nextEditorInGroup"
    },
    {
        "key": "ctrl+alt+left",
        "command": "workbench.action.previousEditorInGroup"
    }

Keeping one of them pressed or rapidly running them will repro for me.

I have added a trace to figure out who changes the cursor position, and the only trace that shows up is the restoreViewState call. I can only assume that there might be some race in textFileEditor.ts. IIRC, we've seen something similar in the past where the title of the tab would reflect the new file, while the content would reflect the old file. Perhaps this is a variation of the same problem.

setStates 
    at Cursor.setStates (file:///Users/alex/src/vscode/out/vs/editor/common/controller/cursor.js:127:40)
    at Cursor.restoreState (file:///Users/alex/src/vscode/out/vs/editor/common/controller/cursor.js:197:18)
    at CodeEditor.CommonCodeEditor.restoreViewState (file:///Users/alex/src/vscode/out/vs/editor/common/commonCodeEditor.js:456:33)
    at CodeEditorWidget.restoreViewState (file:///Users/alex/src/vscode/out/vs/editor/browser/widget/codeEditorWidget.js:291:47)
    at file:///Users/alex/src/vscode/out/vs/workbench/parts/files/browser/editors/textFileEditor.js:104:36
    at Object.notifySuccess [as _notify] (file:///Users/alex/src/vscode/out/vs/base/common/winjs.base.raw.js:1170:59)
    at Object.enter (file:///Users/alex/src/vscode/out/vs/base/common/winjs.base.raw.js:852:30)
    at _Base.Class.derive._creator._run (file:///Users/alex/src/vscode/out/vs/base/common/winjs.base.raw.js:1068:29)
    at _Base.Class.derive._creator._completed (file:///Users/alex/src/vscode/out/vs/base/common/winjs.base.raw.js:1036:18)
    at CompletePromise_ctor.CompletePromise_then [as then] (file:///Users/alex/src/vscode/out/vs/base/common/winjs.base.raw.js:1566:49)

@alexdima alexdima reopened this Jan 8, 2018
@alexdima alexdima added workbench-editors Managing of editor widgets in workbench window and removed editor info-needed Issue requires more information from poster labels Jan 8, 2018
@alexdima alexdima assigned bpasero and unassigned alexdima Jan 8, 2018
@bpasero bpasero added this to the December 2017/January 2018 milestone Jan 8, 2018
@bpasero bpasero added the bug Issue identified by VS Code Team member as probable bug label Jan 8, 2018
@bpasero
Copy link
Member

bpasero commented Jan 8, 2018

Yeah indeed same underlying issue as #34697. Marking as duplicate.

@bpasero bpasero closed this as completed Jan 8, 2018
@bpasero bpasero added the *duplicate Issue identified as a duplicate of another issue(s) label Jan 8, 2018
@bpasero bpasero reopened this Jan 9, 2018
@bpasero bpasero removed the *duplicate Issue identified as a duplicate of another issue(s) label Jan 9, 2018
@bpasero
Copy link
Member

bpasero commented Jan 9, 2018

Found a workaround by checking that the view state we want to save has the same URI as the input we save it for.

@aeschli
Copy link
Contributor

aeschli commented Feb 1, 2018

Verified that cursor position is lot lost, but I see a similar issue with folding regions: #42738

@aeschli aeschli added the verified Verification succeeded label Feb 1, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded workbench-editors Managing of editor widgets in workbench window
Projects
None yet
Development

No branches or pull requests

4 participants