Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Get current open file/project #38

Open
TTitcombe opened this issue Dec 1, 2021 · 3 comments
Open

Get current open file/project #38

TTitcombe opened this issue Dec 1, 2021 · 3 comments

Comments

@TTitcombe
Copy link

Is there a way through the extension to get the filename and path to the currently open file or project in the editor? Something like pathlib.Path.cwd doesn't work if the user navigates to a different project within VSCode

@Makiyu-py
Copy link
Collaborator

I believe there's ActiveTextEditor.document to get the currently opened text document

@Nicholas-Schaub
Copy link
Contributor

Currently, the Python script you write has the default file path set to the home directory. In #25 I mentioned I have created a fox for this, and I plan on opening a PR for it. Maybe @CodeWithSwastik can comment on this. My approach to implementing this is to grab the vscode workspace directory in JavaScript and pass it in as an input argument to the Python script. From there, the Python script sets the working directory to the vscode workspace directory.

@SmartManoj
Copy link

active_text_editor = await ctx.window.active_text_editor
file_name = active_text_editor.document.fileName

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants