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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move the repl input code to its own file #10083

Merged
merged 4 commits into from Mar 20, 2024

Conversation

lf-
Copy link
Member

@lf- lf- commented Feb 26, 2024

Motivation

This is in preparation for #10075 which adds an automation mode to the repl that bypasses readline.

In order to make implementing that nice, I decided to do a refactoring to move all the repl input code into its own file and split it out of the repl proper. This keeps all the readline jank in one place and makes the repl more maintainable.

I split this into a separate PR to make it easier to review.

Context

Priorities and Process

Add 馃憤 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@lf- lf- requested a review from edolstra as a code owner February 26, 2024 09:17
@github-actions github-actions bot added the repl The Read Eval Print Loop, "nix repl" command and debugger label Feb 26, 2024
@lf- lf- force-pushed the jade/refactor-repl-input branch 2 times, most recently from 7d74a25 to 7abbeed Compare February 26, 2024 09:29
Comment on lines +127 to +136
static constexpr const char * promptForType(ReplPromptType promptType)
{
switch (promptType) {
case ReplPromptType::ReplPrompt:
return "nix-repl> ";
case ReplPromptType::ContinuationPrompt:
return " ";
}
assert(false);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

the only actual new code in here

rl_set_complete_func(completionCallback);
rl_set_list_possib_func(listPossibleCallback);
#endif
return restoreRepl;
Copy link
Member Author

Choose a reason for hiding this comment

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

This used to be a Finally in caller scope so we have to hoist it to the caller by returning it now. Nothing else is changed in this function.

@lf-
Copy link
Member Author

lf- commented Feb 26, 2024

doesn't compile under clang huh, will fix later

@lf- lf- marked this pull request as draft February 26, 2024 10:17
@lf- lf- marked this pull request as ready for review February 27, 2024 05:34
@lf-
Copy link
Member Author

lf- commented Feb 27, 2024

sigh. does not compile because the stdenv on macOS is using clang 11 and libc++ 11. this is so silly. that stuff is approaching 4 years old.

i will figure out a fix.

@lf-
Copy link
Member Author

lf- commented Feb 27, 2024

Would be fixed by: #9546

@roberth
Copy link
Member

roberth commented Feb 28, 2024

Would be fixed by: #9546

Merged 馃帀

@lf- lf- force-pushed the jade/refactor-repl-input branch 2 times, most recently from e97087d to 9c56a9c Compare February 28, 2024 20:26
free(vp[ac]);
free(vp);
}
throw Error("allocation failure");
Copy link
Member Author

Choose a reason for hiding this comment

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

It is probably a bad idea/unsound to unwind through libreadline, resulting in the terminal not being reset! But I'm not fixing it in this PR as this PR is just moving code around.

@lf-
Copy link
Member Author

lf- commented Feb 28, 2024

Merge conflicts fixed and it's expected to compile; this is now reviewable.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-03-04-nix-team-meeting-minute-130/40830/1

@lf- lf- force-pushed the jade/refactor-repl-input branch 2 times, most recently from 9c56a9c to cc36428 Compare March 13, 2024 01:53
@roberth roberth merged commit 7d2ead5 into NixOS:master Mar 20, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repl The Read Eval Print Loop, "nix repl" command and debugger
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants