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

window.showTextDocument Performance Problems #12280

Closed
anthonydresser opened this issue Sep 19, 2016 · 13 comments
Closed

window.showTextDocument Performance Problems #12280

anthonydresser opened this issue Sep 19, 2016 · 13 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@anthonydresser
Copy link
Contributor

anthonydresser commented Sep 19, 2016

  • VSCode Version: 1.5.2
  • OS Version: OSX 10.11.6

Steps to Reproduce:

  1. Show a text document
  2. With that document still in focus, attempt to call showTextDocument with the document object.

window.showTextDocument seems to have performance problems (1-1.5 second promise resolve) when calling it with a document that is already in focus.

Calling showTextDocument on a document that is open but not in focus for one of the editor windows does not show this performance problem.

Edit: Clarification: This seems to be a performance problem specifically for the promise resolving. You can visually see the window come into focus in a reasonable amount of time, but the promise resolving with the editor object is greatly delayed.

@chrmarti chrmarti added the bug Issue identified by VS Code Team member as probable bug label Sep 20, 2016
@alexdima alexdima assigned jrieken and unassigned alexdima Sep 20, 2016
@jrieken
Copy link
Member

jrieken commented Sep 20, 2016

Could be due to this

@anthonydresser
Copy link
Contributor Author

I was looking at this when debugging the problem, however, the vscode debugger for extensions doesn't work perfectly when it starts to dig into the vscode code. One work around I was thinking of that I couldn't find a way to do, is simply check if the file is currently showing in one of the editor windows. However it appears the only related call is the getter for activetexteditor, but this only gives you the active editor for the current window in focus.

Is there a way to get the active editors for all the open windows? I.E can you get the editor that is currently open in the other windows when you have 2 or 3 files open side by side?

@alexdima
Copy link
Member

I think visibleEditors gives all the ones that are visible. But that one has the problem that it is lacking an event.

@anthonydresser
Copy link
Contributor Author

It seems checking visibleEditors works around the problem. Thanks for the reference.

@DanTup
Copy link
Contributor

DanTup commented Nov 18, 2016

This problem affects Dart Code - I was going to try and implement this workaround, but the show method on TextEditor is marked as deprecated:

* @deprecated **This method is deprecated.**
* Use window.showTextDocument instead. This method shows unexpected behavior and will be removed in the next major update.

Is there any other workaround for this that won't break in an upcoming update?

@jrieken
Copy link
Member

jrieken commented Nov 18, 2016

window.showTextDocument seems to have performance problems (1-1.5 second promise resolve) when calling it with a document that is already in focus.

@anthonydresser @DanTup Is opening the same document in the same editor column (basically a no-op) the slow case or when opening the same document in another column?

@DanTup
Copy link
Contributor

DanTup commented Nov 18, 2016

@jrieken The no-op scenario is slow too. Our code is like this:

vs.workspace.openTextDocument(location.file).then(document => {
    vs.window.showTextDocument(document).then(editor => {
        let range = toRange(location);
        editor.revealRange(range, vs.TextEditorRevealType.InCenterIfOutsideViewport);
        editor.selection = new vs.Selection(range.end, range.start);
    });
});

We open the document then need the editor so that we can jump to the correct place. Even when everything is in one file there's a second delay between this code executing and the selection moving (inside the same file).

@jrieken
Copy link
Member

jrieken commented Nov 18, 2016

Understood. The 1 second might come from here but I was assuming openEditor returns the editor when it's already open...

@jrieken jrieken added this to the November 2016 milestone Nov 18, 2016
@jrieken
Copy link
Member

jrieken commented Nov 18, 2016

Actually, this should be easy to fix

@DanTup
Copy link
Contributor

DanTup commented Nov 18, 2016

Great! Let me know if you'd like me to test with our code once it's in Insiders.

@jrieken
Copy link
Member

jrieken commented Nov 18, 2016

Thanks - should be in insiders on Monday

@DanTup
Copy link
Contributor

DanTup commented Nov 25, 2016

@jrieken this is working great in Insiders now, it's instant with no delay 👍

@ramya-rao-a
Copy link
Contributor

Marking as verified as per @DanTup's confirmation

@ramya-rao-a ramya-rao-a added the verified Verification succeeded label Dec 7, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
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
Projects
None yet
Development

No branches or pull requests

6 participants