VSCode - 打开/选择非文本文件时触发的事件 [英] VSCode - Event that fires when a non-text file has been opened / selected

查看:31
本文介绍了VSCode - 打开/选择非文本文件时触发的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 VSCode 中,当活动的 text 编辑器被更改时会发生一个事件:onDidChangeActiveTextEditor,当不是文本文件的文件被更改时它不会触发打开(例如图像).我搜索了 VSCode API,并用谷歌搜索了它,但没有找到任何东西.

In VSCode there is an event when the active text editor has been changed: onDidChangeActiveTextEditor, it doesn't fire when a file that isn't a text file is opened (for example an image). I searched the VSCode API, and googled it, but didn't find anything.

虽然 onDidChangeActiveTextEditor 事件会在选择文本文件然后选择图像文件时触发,但在选择图像文件并选择另一个图像文件时不会触发.

Although the onDidChangeActiveTextEditor event does fire when a text file is selected and then you select an image file, it doesn't fire when you have an image file selected and you select another image file.

所以我的问题是当在资源管理器中选择任何文件时是否会触发一个事件,或者我是否使用onDidChangeActiveTextEditor忽略了某些内容?

So my question is is there an event that will fire when any file is selected in the explorer, or am I overlooking something with onDidChangeActiveTextEditor?

看起来有一个悬而未决的问题:https://github.com/Microsoft/vscode/issues/15178

Looks like there is an open issue for this: https://github.com/Microsoft/vscode/issues/15178

推荐答案

为了清楚说明这个问题已经得到解答,我使用 OP 编辑​​过的问题信息来做出正确的回答:

To make it clear this question has been answered, I'm using the OP's edited question information to make a proper answer:

  • 目前 (VSCode 1.37.1) 没有此类事件来侦听活动非文本编辑器的更改.
  • 有一个开放的 VSCode 问题 15178,表面上会跟踪此请求.
  • 但是,在我看来,14483 确实是正确的问题,并且结束它作为重复是一个错误.(15178 是关于枚举打开的编辑器,而只有 14483 专门针对通知事件.)
  • There is currently (VSCode 1.37.1) no such event to listen for changes to active non-text editors.
  • There is an open VSCode issue, 15178, that ostensibly tracks this request.
  • However, in my opinion, 14483 is really the right issue, and closing it as a duplicate was a mistake. (15178 is about enumerating open editors, while only 14483 specifically addresses notification events.)

这篇关于VSCode - 打开/选择非文本文件时触发的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆