You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
debug window is unexpectedly considered a "text editor" #45188
There are some events and properties related to text editors:
window.activeTextEditor
window.onDidChangeActiveTextEditor
These sound perfect for something I'm doing - rendering an explorer tree with an outline of the current document. The docs describe the active editor as "The active editor is the one that currently has focus or, when none has focus, the one that has changed input most recently".
However, they fire for things I wouldn't consider "text editors". When I click the debug window the event fires and the activeTextEditor is updated to something with a document that has the URI debug:input.
This makes it difficult to track the last actual document the user interacted with (which is what the description of window.activeTextEditor suggests it does). While we could skip over changes from non-documents it then would be difficult to track when the last document we're tracking was closed (since it could be closed without firing another window.activeTextEditor.
I don't know if this is a bug, but if it's not, I think there shoud be a way to track what the user would consider a text document.
Reacted by Paul Riding, MikeT, Anatoly Pulyaevskiy, Danny Tuppeny and Victor Choueiri
The suggestion is to use vscode.window.activeTextEditor.viewColumn to decide whether the event is for a real document or not. I think this is a bad fix, as window.activeTextEditor won't give you what you want.
The workaround seems flawed. If you click in the debug window and then click File -> Close Editor then you don't get notification of that editor going away.
Johannes Rieken (@jrieken) This may be a good case for the proposed generic editor APIs (such as onDidChangeActiveEditor) to handle. Debug console could have its own distinct type
changed the title [-]debug window is unexpected considered a "text editor"[/-][+]debug window is unexpectedly considered a "text editor"[/+]on Mar 7, 2018
closing as dupe of #16478 and flagging 'as-designed' because we currently cannot change these things, esp the debug console wants to be an editor for supporting vim and language smarts, e.g. IntelliSense in the debug console.
Johannes Rieken (@jrieken) Understood, but there's still a bug that the ts extension can't easily fix. Should I raise a case for the ts extension to add a workaround or is there a future feature that will address this? Although the ts bug is minor (it's just status text) I'm using the same functionality for a contributed tree and having stale content there is far worse, it feels really broken.
Matt Bierner (@mjbvz) Feel free to rename this if your intention is to fix in the ts extension, but lmk if you find a reliable fix (ideally that works globally, not just for the one instance I managed to find with a quick test) since I desperately need it too! ;(
Johannes Rieken (@jrieken) I think the point is that we need a new API or an API change. Extensions can't solve this problem without maintaining their own model of the editor UI
Danny Tuppeny (@DanTup) You'll probably need to look into a workaround on your side as I don't see myself getting around to the TS-specific issue in the near term. The TS problem is very low impact and it self corrects as soon as you go back to an editor
Matt Bierner (@mjbvz) Understood, thanks! Our feature is blocked by quite a few issues in Code (listed here) so it might be a while before we can ship this anyway, so I'll leave finding a workaround till later in the hope a better solution comes along.
I saw this in the release notes; is it a fix for this issue?
Simple editors are not passed to extensions
Inputs that use the editor like the debug REPL input are no longer passed to extensions as editors. This means that both the onDidChangeActiveTextEditor will not trigger when user focuses the debug REPL, and that the onDidChangeTextDocument will also not fire. The reason behind this change is that the REPL input uses the editor as an implementation detail and extension should not be notified of this since it is not a "real editor".
Activity
DanTup commentedon Mar 7, 2018
Looks like this has been discussed before:
#16478
The suggestion is to use
vscode.window.activeTextEditor.viewColumnto decide whether the event is for a real document or not. I think this is a bad fix, aswindow.activeTextEditorwon't give you what you want.DanTup commentedon Mar 7, 2018
The workaround seems flawed. If you click in the debug window and then click
File -> Close Editorthen you don't get notification of that editor going away.As such, #16478 is still somewhat reproducible in TypeScript even after Matt Bierner (@mjbvz)'s fix in
379da6b.
File -> Close EditorIf this isn't fixed in the API, extension authors are all going have to put nasty hacks in to handle these cases :(
mjbvz commentedon Mar 7, 2018
Johannes Rieken (@jrieken) This may be a good case for the proposed generic editor APIs (such as
onDidChangeActiveEditor) to handle. Debug console could have its own distinct type[-]debug window is unexpected considered a "text editor"[/-][+]debug window is unexpectedly considered a "text editor"[/+]jrieken commentedon Mar 8, 2018
closing as dupe of #16478 and flagging 'as-designed' because we currently cannot change these things, esp the debug console wants to be an editor for supporting vim and language smarts, e.g. IntelliSense in the debug console.
DanTup commentedon Mar 8, 2018
Johannes Rieken (@jrieken) Understood, but there's still a bug that the ts extension can't easily fix. Should I raise a case for the ts extension to add a workaround or is there a future feature that will address this? Although the ts bug is minor (it's just status text) I'm using the same functionality for a contributed tree and having stale content there is far worse, it feels really broken.
jrieken commentedon Mar 8, 2018
Yeah, up to Matt Bierner (@mjbvz)
DanTup commentedon Mar 8, 2018
Matt Bierner (@mjbvz) Feel free to rename this if your intention is to fix in the ts extension, but lmk if you find a reliable fix (ideally that works globally, not just for the one instance I managed to find with a quick test) since I desperately need it too! ;(
mjbvz commentedon Mar 8, 2018
Johannes Rieken (@jrieken) I think the point is that we need a new API or an API change. Extensions can't solve this problem without maintaining their own model of the editor UI
Danny Tuppeny (@DanTup) You'll probably need to look into a workaround on your side as I don't see myself getting around to the TS-specific issue in the near term. The TS problem is very low impact and it self corrects as soon as you go back to an editor
DanTup commentedon Mar 8, 2018
Matt Bierner (@mjbvz) Understood, thanks! Our feature is blocked by quite a few issues in Code (listed here) so it might be a while before we can ship this anyway, so I'll leave finding a workaround till later in the hope a better solution comes along.
DanTup commentedon Apr 7, 2018
I saw this in the release notes; is it a fix for this issue?
jrieken commentedon Apr 9, 2018
Yes
DanTup commentedon Apr 10, 2018
Excellent, thank you! 👍