eclipse-theia/theia

vscode.window.visibleTextEditors does not work correctly when opening a webview

Open

#10189 opened on Sep 29, 2021

View on GitHub
 (1 comment) (0 reactions) (0 assignees)TypeScript (18,676 stars) (2,478 forks)batch import
help wantedvscode

Description

Bug Description:

Hi, I am building a vscode extension to be used in Theia, and I think the vscode.window.visibleTextEditors does not work as expected. Once opening a non-text editor tab (custom editor OR any web view or just the getting started page for example), and then trying to fetch the visibleTextEditors, I still get the last INVISIBLE text editor!

I need this functionality in order to post a message to the active/visible editor that could be a normal text editor or any web-view, but from both vscode.window.activeTextEditor and vscode.window.visibleTextEditors APIs I can't determine the type of the currently opened tab (I can manage my custom editor visibility by used the onDidChangeViewState event).

Also, the visible/active editor changer should affect the status bar and the scode.window.onDidChangeVisibleTextEditors event.

Steps to Reproduce:

  1. regester a command that executes this code: vscode.window.visibleTextEditors.forEach(e=>vscode.window.showInformationMessage(e.document.uri.fsPath));
  2. open 2 text editors
  3. call the command, you will get the visible editor path
  4. open the Preferences tab or the Getting started page, and then call the command again, you will get the last active text editor tab although it is not visible.

Additional Information

  • Operating System: Windows 10
  • Theia Version: Theia 1.16

Contributor guide