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

Rework how the project directory is determined for jack-in and connect #275

Merged
merged 15 commits into from
Aug 12, 2019

Conversation

PEZ
Copy link
Collaborator

@PEZ PEZ commented Aug 7, 2019

First we try find the workspace root, then we add custom sub dir

Hello, can you review this fix of getProjectDir() for me? It is not supposed to add any fancy new possibilities, just fix so that a custom project root (sub directory) should work in more cases. It is a very central function so I'd appreciate an extra brain on it. Cheers!

First we try find the workspace root, _then_ we add custom sub dir
@PEZ PEZ requested a review from kstehn August 7, 2019 14:27
@PEZ
Copy link
Collaborator Author

PEZ commented Aug 7, 2019

Please merge it if you think it is good enough. 😄

Copy link
Contributor

@kstehn kstehn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
But i think i found a problem , and it might be the reason why i thought this is buggy.

When you Jack-In the Terminal says "Executing task in folder ...."
After that i always canceled the process. This time i just let it run and it is the right Project.
But i have no idea where that might happen

@PEZ
Copy link
Collaborator Author

PEZ commented Aug 8, 2019

I think I might have been using the wrong constructor overload for the Task all this time. Fixed that now. Can you try and see if it fixes the problem? If so we should have a much more reliable jack-in for projects not in the workspace root now.

PEZ added 3 commits August 9, 2019 11:09
Removes `projectRootDir` setting and uses this logic instead:

1. If there is no file open. Stop and complain.
2. If there is a file open, use it to determine the project root
by looking for project files from the file's directory and up to
the window root (for plain folder windows) or the file's
workspace folder root (for workspaces) to find the project root.
Return
1. the window root for plain folders
2. first workspace root for workspaces.
calva/connector.ts Outdated Show resolved Hide resolved
@kstehn
Copy link
Contributor

kstehn commented Aug 9, 2019

Also like we discussed to remind you, add some documentation to the function that you are currently working on :).

@PEZ PEZ changed the title Apply custom project root last Rework how the project directory is determined for jack-in and connect Aug 10, 2019
@PEZ
Copy link
Collaborator Author

PEZ commented Aug 10, 2019

Now I have made the project root something we need to initialize as the start of the jack-in and (standalone) connect processes. When the path is actually needed, this initialized value will be used. Should be both more efficient and less error prone.

I also added that doc string, finally. 😄 Which was a very good thing to add, because the way I had phrased the strategy used... It made me realize that this new way of finding the project files isn't implementing that strategy! This will now fail for the ”plain” folder, multi-project case. (I haven't tested that yet, but I am pretty certain.) Committing this anyway, so that I can get your help with sanity checking the general change for init-then-use.

Will restore the old new way of finding the project files now. Then, maybe, this is closing in on being ready to merge.

@PEZ
Copy link
Collaborator Author

PEZ commented Aug 10, 2019

This now works for the plain folder multi project case. I've tested it with Leiningen, Clojure CLI and shadow-cljs. An inconvenience is that Calva remembers the jack-in and connect picker selections per workspace which can be confusing and trick people to accept the wrong defaults. I think we should fix that before shipping. What say you?

I'll make some tests with a real workspace now. Please put it to a test on your side as well.

@PEZ
Copy link
Collaborator Author

PEZ commented Aug 10, 2019

VSIX package built and sent to calva-dev in Clojurians Slack. Let's give it a day or two. If no one reports a problem, then merge! 😄

@kstehn kstehn merged commit 66dc266 into master Aug 12, 2019
@PEZ PEZ deleted the fix-custom-project-root branch August 12, 2019 21:13
@mrkam2
Copy link
Contributor

mrkam2 commented Feb 3, 2021

Hi @PEZ I found that broke my Jack-In presets. I need "projectRootDir" setting so that I can choose another project having the same source file. Is it possible to restore it?

@mrkam2
Copy link
Contributor

mrkam2 commented Feb 3, 2021

Sorry, I got it wrong. I was actually using a custom Calva build from #580.

@PEZ
Copy link
Collaborator Author

PEZ commented Feb 3, 2021

So you're good now?

@mrkam2
Copy link
Contributor

mrkam2 commented Feb 3, 2021

So you're good now?

Thanks for checking.

I need that PR to be merged (as I need projectRootDir setting). I have a temporary workaround for now.

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

Successfully merging this pull request may close these issues.

3 participants