Update status bar when opening a binary file as text#59914
Update status bar when opening a binary file as text#59914bpasero merged 2 commits intomicrosoft:masterfrom
Conversation
|
@atitoa93 yeah we still need that other listener unfortunately otherwise the editor status does not update when you click between 2 opened editors in 2 separate groups. |
|
Ops, Nice catch 👍 |
3bbe23b to
62b5a14
Compare
|
Yeah, this works, though now we update 2 times when opening an editor. I was hoping for a solution where we maybe have a new event that is very specific to this case (opening a binary file) that the editor status could listen to (similar to the encoding change). I realize this is a bit more work, so I can also try to come up with a bit more advice as needed. |
|
@bpasero Here is the approach I came up with.
What do you think? |
|
@atitoa93 yes something like that, it should be another thing we could add to |
|
@bpasero While developing the approach I mentioned above, came to my mind a more elegant and generic solution. All that I have to do is considering |
62b5a14 to
f005614
Compare
|
@atitoa93 I thought about that too, but that solution you implemented makes it very specific to file editor inputs and we would have to add more custom code for other inputs that behave similar. That is why I would prefer either my initial idea or a more generic approach that works for all editors. |
|
@bpasero I see what you mean. What about applying the same technique but with the |
|
@atitoa93 I find it weird to have a property/method for this "state", when is this state being reset? An event would make much more sense imho. |
f005614 to
a9fa622
Compare
|
@bpasero I did the change to be an event instead of an attribute, but there is something weird happening, It renders only the selection change. I spent a lot of time trying to figure out why but I couldn't. Any help will be appreciated. |
|
@atitoa93 instead of listening on the level of the editor service, why not just listen at the place where it is needed (around here): https://github.com/Microsoft/vscode/blob/c09511ccc1f67b08ebda9141d49a030cc381865e/src/vs/workbench/browser/parts/editor/editorStatus.ts#L566 There is already an array of active editor listeners that will get cleaned up when the editor changes. To get to the editor, just call |
a9fa622 to
0815b91
Compare
|
@bpasero I tried that before but it rendered the selection change only. And I thought I have to call |
|
@atitoa93 so you say this does not work: this.activeEditorListeners.push(activeEditor.onDidOpenInPlace(() => {
this.updateStatusBar();
}));Can you debug what happens in the |
|
@bpasero Quick update: it works fine if I run it on debugger mode and putting a breakpoint in |
0815b91 to
74b5e8d
Compare
|
@bpasero So after a debugging session lasts for a couple of hours, I couldn't discover what exactly causes the problem. But, what is happening is the execution of |
|
@atitoa93 I like your solution very much, fixed the timeout. Thanks! |
Fixes #59832
WIP: Making sure no extra work happen if the active editor remains the same. More information in the issue comments.