VS 代码扩展:vscode.window.activeTextEditor == 未定义 [英] VS-Code Extension: vscode.window.activeTextEditor == undefined

查看:34
本文介绍了VS 代码扩展:vscode.window.activeTextEditor == 未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个 Visual Studio Code 扩展.基于这个例子:https://github.com/Microsoft/vscode-extension-samples/tree/master/previewhtml-sample

I wrote an Visual Studio Code extension. Based on this example: https://github.com/Microsoft/vscode-extension-samples/tree/master/previewhtml-sample

var editor = vscode.window.activeTextEditor;
if (!editor) {
    console.log("No open text editor");
}

如果我打开一个 2MB 的文件,这可以正常工作.但如果文件大于或等于 5MB,则不会.

This works fine if i open a 2MB File. But not if the file is 5MB or larger.

但是如果我复制 (Ctrl+C,Ctrl+V) 一个 10MB 到一个新的编辑器它会工作并且非常快.有谁知道这是一种什么样的限制?

But if I copy (Ctrl+C,Ctrl+V) a 10MB into a new editor it will work and is prety fast. Has anyone an idea what kind of limitation this is?

或者是否可以通过一些方法让用户在命令中选择文件.直接读取文件?

Or is there perhaps a work around by some how let user choose a file in command. To directly read the file?

推荐答案

这已在上游 中解决这个问题

根本原因是 VS Code 没有为超过一定大小的文件正确创建文本编辑器.此大小限制已增加,但对于非常大的文件,您仍然可能会遇到此限制

The root cause was that VS Code did not properly create text editors for files over a certain size. That size limit has since increased but you still may run into this limitation for very large files

这篇关于VS 代码扩展:vscode.window.activeTextEditor == 未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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