Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot execute command because there is no active text editor when file is not tokenized #146784

Closed
soulshined opened this issue Apr 5, 2022 · 2 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s)

Comments

@soulshined
Copy link
Contributor

soulshined commented Apr 5, 2022

Does this issue occur when all extensions are disabled?: Not Applicable

I have an extension called Go To Character Position

TLDR; it's like jump to line/col but let's you jump to absolute indices of characters.

The relevant code doesn't do anything extravagant and is pretty straight forward. I've received a couple reports about 'large' files not doing anything. I was able to get my hands on a file provided by one of the users to troubleshoot with. A compressed version can be reviewed here on my onedrive, but if you don't feel comfortable downloading that, it's basically a 300MB json payload, which obviously won't be tokenized/parsed for regions.

My analysis has led me to believe that either:

  1. commands aren't executed for files that don't get tokenized/parsed
  2. commands are registered but files that don't get tokenized/parsed are not considered 'active text editors' when the cursor is in them per normal usage.

For brevity, the command has a when clause:

"command": "go-to-character-position.go-to-character-position",
"key": "ctrl+k ctrl+g",
"mac": "cmd+k cmd+g",
"when": "editorTextFocus"

And registered with in the following manner:

vscode.commands.registerTextEditorCommand(COMMANDS.go_to_character_position, async function (editor) {

I have read the docs and don't see anything addressing limitations or assumptions to consider around these scenarios.

https://code.visualstudio.com/api/references/vscode-api#commands.registerTextEditorCommand

I would like to know if my assumptions are valid, in that an editor is not considered 'active' if it is not tokenized/parsed, even if the cursor is actively in the editor, or are those just red herrings? If so, what are the preferred api ways to address this?


  • VS Code Version:
    Version: 1.66.0 (system setup)
    Commit: e18005f
    Date: 2022-03-30T05:50:14.623Z
    Electron: 17.2.0
    Chromium: 98.0.4758.109
    Node.js: 16.13.0
    V8: 9.8.177.11-electron.0
    OS: Windows_NT x64 10.0.19043

Steps to Reproduce:

  1. Open large file (Not sure about size or character limits), but large being beyond reasonable

  2. Get Notification about tokenization/parsing for regions (though enabling this has no positive effect, which is why i'm not certain they are related, possibly circumnstantial):
    Screenshot 2022-04-04 184004

  3. Click on the editor text and ensure cursor is present in the editor

  4. Type >Go to Character Position in the command palette and press enter

  5. Nothing happens

  6. Logs display no active text editor is present:
    Screenshot 2022-04-04 184021

@alexdima
Copy link
Member

alexdima commented Apr 5, 2022

We intentionally don't sync large documents to the extension host. The current limit is 50 MB. Let's track in #31078

@alexdima alexdima closed this as completed Apr 5, 2022
@alexdima alexdima added the *duplicate Issue identified as a duplicate of another issue(s) label Apr 5, 2022
@soulshined
Copy link
Contributor Author

Thanks @alexdima it would be useful for that to be documented somewhere in the API docs, but a quick answer nonetheless! Thanks for the follow up

@github-actions github-actions bot locked and limited conversation to collaborators May 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

2 participants