visual-studio-code - 无法在其他视图列中获得可见的文本编辑器
问题描述
我正在尝试在新的视图列中打开活动文件,然后折叠标签。折叠命令可以正常工作activeTextEditor
:
// Fold based on linenumber
let range = editor.document.lineAt(lineNumber).range;
editor.selection = new vscode.Selection(range.start, range.end);
editor.revealRange(range);
commands.executeCommand('editor.fold');
现在我想在新打开的文件中做同样的事情:
// Open the same file in a new column
// at this time editor.ViewColum is One
commands.executeCommand('vscode.open', Uri.file(editor.document.fileName), ViewColumn.Two);
// Try to get that editor
let newEditor = vscode.window.visibleTextEditors.find(x=> x.viewColumn===viewColumn.Two && x.document.fileName===fileName)
问题是newEditor
没有找到,因为新打开的文档有ViewColumn
undefined
.
知道如何解决这个问题吗?
谢谢
解决方案
vs 命令返回一个承诺。需要等待,一切正常。
推荐阅读
- docker - Hyperledger Fabric V1.2 网络设置与 Zookeeper 和 Kafka 用于多个订购者
- php - 您如何使用 php 制作一个基于 Web 服务器中即将到来的日期发送电子邮件的 Web 应用程序?
- reactjs - 在 React 中实现的登录页面生成 toast:am(...).updateCurrentUser 不是一个函数
- parameters - 网址查询字符串,平均堆栈
- bubble-sort - 插入和冒泡算法理论
- python - 禁用所有打印,除了在调用函数中完成的打印
- arrays - array.insert at:替换项目而不是在Swift中的指定位置插入,为什么?
- typescript - Chrome/Firefox/Edge 扩展 - 谷歌分析
- java - 仅使用运行时数据查找大 O 时间复杂度函数
- r - 在 R 中生成具有不同样本大小的多项随机变量