VS 代码扩展:vscode.window.activeTextEditor == 未定义

编程入门 行业动态 更新时间:2024-10-25 18:32:34
本文介绍了VS 代码扩展:vscode.window.activeTextEditor == 未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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

I wrote an Visual Studio Code extension. Based on this example: https://github/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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-27 04:42:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1148586.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   未定义   window   vscode   activeTextEditor

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!