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

Make "Build and Run" action work irrespective of current working directory #45

Merged
merged 1 commit into from
Apr 27, 2022

Conversation

petervdonovan
Copy link
Contributor

This changes the working directory before running any commands. Unfortunately there is no way to check if the user has changed to a different working directory, so this action will be performed unconditionally when the "Build and Run" action is triggered.

The request was to use absolute paths instead of relative paths. This does not do that because this method was easier to implement, and because it might be more robust if we have run commands that behave differently according to the current working directory. If we really want absolute paths, then that is no problem, but it would just take some more testing and changes in the lingua-franca main repo.

@petervdonovan petervdonovan linked an issue Apr 27, 2022 that may be closed by this pull request
@@ -98,8 +97,7 @@ export async function activate(context: ExtensionContext) {
name: runTerminalName,
cwd: command[0]
});
else if (lastWorkingDirectory !== command[0]) terminal.sendText('cd ' + command[0]);
lastWorkingDirectory = command[0];
terminal.sendText('cd ' + command[0]);
Copy link
Member

Choose a reason for hiding this comment

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

I haven't tried this yet, but if command[0] is not an absolute path, then wouldn't the cd fail in case the shell is not in the right directory to begin with?

Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't a more obvious fix be to remove the if statement on line 97, always creating a new terminal regardless of whether one exists already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

command[0] is an absolute path. Only the command itself uses a possibly relative path.

The problem with creating a new terminal each time is that they can accumulate and cause clutter, as shown below:

Screenshot from 2022-04-26 22-06-47

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha. Yes, if command[0] is absolute, then this will work. Great! Thanks for the fix!

@lhstrh lhstrh changed the title Fix #43. Make "Build and Run" action work irrespective of current working directory Apr 27, 2022
@lhstrh lhstrh merged commit 88fd1f9 into main Apr 27, 2022
@lhstrh lhstrh deleted the fix-43 branch April 27, 2022 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Build and Run" should use full path
2 participants