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

Always access to the file-path of the text editor #138523

Closed
mtirionMSFT opened this issue Dec 6, 2021 · 6 comments
Closed

Always access to the file-path of the text editor #138523

mtirionMSFT opened this issue Dec 6, 2021 · 6 comments
Labels
editor-api Issues about the API of vscode in the area of editors feature-request Request for new features or functionality

Comments

@mtirionMSFT
Copy link

I'm creating a VSCode Notebook extension. The notebook is about parsing Liquid (a templating language). Besides the liquid template fragments you type in code blocks it can also use the users data-files and Liquid templates on disk. That's all handled by a parser I include in the extension. To have a configuration per notebook, I've added a 'Settings' language to my notebook where you can do something like:

DATA .\Data
TEMPLATES .\Templates

The provided paths can be absolute, but also relative. My idea is that relative paths are resolved from the location of the notebook in the editor. Currently the way to get the file-path of the open text editor in code is through this piece of code:

vscode.window.activeTextEditor?.document.uri.fsPath

The problem is that if the file gets larger than 50 MB, activeTextEditor returns undefined (because of memory saving. See #32118). I understand that this is done for the contents of the file, but now it's a bit weird behavior now when the activeTextEditor is set or undefined. I have a notebook currently 8 KB in size (so, very small) and in one run of the code activeTextEditor is set, a few milliseconds later it's undefined.

Request: I would like to have a standard way to obtain the path of the file in the text editor at all times, even if it's larger then 50MB.

@jrieken jrieken assigned alexdima and unassigned jrieken Dec 6, 2021
@jrieken
Copy link
Member

jrieken commented Dec 6, 2021

There are no plans to have an editor without a document. There are plans to expose editor tabs (see #133532) independent of the actual editor.

Forwarding to Alex for the actual limit of 50MB but I don't believe there are plans to change that.

@alexdima alexdima added editor-api Issues about the API of vscode in the area of editors feature-request Request for new features or functionality labels Dec 7, 2021
@alexdima alexdima removed their assignment Dec 7, 2021
@mtirionMSFT
Copy link
Author

To better clarify the question: In a Notebook extension I only want to know the path of the file being edited. I don't care for contents of the file through the ActiveEditor. Someone pointed to the new 'tabs-functionality' that might be a solution. As long as I know the path of the current file through that api, that it would be okay. But if there are exceptions there too when data is available, then it's not an option for me.

@jrieken
Copy link
Member

jrieken commented Dec 16, 2021

I don't care for contents of the file through the ActiveEditor.

The API doesn't know the concept of an editor without document. They are strictly coupled and therefore too large documents never have an editor. This will be different for tabs (see linked proposal above)

@github-actions github-actions bot locked and limited conversation to collaborators Mar 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-api Issues about the API of vscode in the area of editors feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants
@jrieken @alexdima @mtirionMSFT and others