Page 1 of 1

How to go to the current file?

Posted: 22.08.2022 06:36
by lookoutside
One of the advantages of Cudatext is project management. It really can manage work by project and switch project is very easy and fast too, much quicker than vscode. But I have a question: How to go to the current file? or How to Locate the current file in the project tree?. When this is done, the folder tree on the project pannel is unfolded and the current file is focused in the tree.

There is not a shortcut or command to do so. I tried recording a macro including the following steps:

1. copy <filename> of the current file
2. go to <file name>
3. paste the copied <file name> in the dialog
4. press enter

step 1 and 2 in the macro works as expected.

Code: Select all

# locate-current-file [Ctrl+J]
ed.cmd(cmds.cmd_CopyFilenameName)
app.app_proc(app.PROC_EXEC_PLUGIN, 'cuda_project_man,menu_goto,')
But step 3 and 4 does not work automatically, I have to use mouse click, pressing Ctrl + V, then Enter.
I think three must be some better way to accomplish the last two steps, can anyone help?

Another requirement:

Perhaps the current project has not been opened when the macro is executed. If so, the cudatext should switch to the corresponding project before it can locate current file. This is possible because that Cudatext knows all the recent projects, and it can compare the current file's path with all the path stored in project settings. The correct path should be decided without difficulty.

This is what I know theoretically, but I don't know how to work out the code. Thanks in advance for anyone who do the work.

Posted: 22.08.2022 08:39
by main Alexey
we have a solution to 'go to current file'.
open Command Palette, enter "project manager" and you will find "project manager: sync to current file". that's it?

Posted: 22.08.2022 08:43
by main Alexey
If so, the cudatext should switch to the corresponding project before it can locate current file. This is possible because that Cudatext knows all the recent projects, and it can compare the current file's path
that requires some Python coding, ie new plugin or additional cmd in the Project Manager. no such command yet. also - each file can be contained in N projects, also - each project can have K>1 root folders. not simple to do.

Posted: 22.08.2022 13:33
by lookoutside
main Alexey wrote:we have a solution to 'go to current file'.
open Command Palette, enter "project manager" and you will find "project manager: sync to current file". that's it?
Yes, this is what I want. The problem is solved, thank you!

Posted: 22.08.2022 13:37
by lookoutside
main Alexey wrote:
If so, the cudatext should switch to the corresponding project before it can locate current file. This is possible because that Cudatext knows all the recent projects, and it can compare the current file's path
that requires some Python coding, ie new plugin or additional cmd in the Project Manager. no such command yet. also - each file can be contained in N projects, also - each project can have K>1 root folders. not simple to do.
I see, thank you. The problem is solved. No need for new plugin now.