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

Fixed a rustfmt tab-related bug, updated dependencies and fixed breaking changes to their APIs #105

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

NotGyro
Copy link

@NotGyro NotGyro commented Oct 22, 2021

Hello, this set of commits fixes a few issues - most prominently, reduce_indent() expects blocks to be indented by four tabs in order to work properly, but setting .rustfmt.toml with "hard_tabs = true" .rustfmt.toml in a project which embeds papyrus would cause blocks to be indented with a \t, breaking this method.

In addition, the versions of several dependencies were bumped. This broke a few things, but most notably parse_program() searches for the string "LexError" to detect a certain result while that syn::parse_str() error is now displayed as "lex error". This case is now checked for.

Copy link
Owner

@kurtlawrence kurtlawrence left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

It looks good, I just have a few changes I would like before I merge it in.

@@ -22,7 +22,7 @@ pub fn parse_program(code: &str) -> InputResult {

let reterr = |e: syn::Error| {
let e = e.to_string();
if &e == "LexError" {
if (&e == "LexError") || (&e == "lex error") {
Copy link
Owner

Choose a reason for hiding this comment

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

Unnecessary parentheses

@@ -44,7 +46,7 @@ pub fn fmt_based_on_terminal_width<D>(repl: &Repl<Print, D>) -> FormattingConfig
std::cmp::max((width * 4) / 5, 120)
}
.saturating_sub(repl.prompt(false).chars().count());
fmt.width_limit = Some(width);
fmt.width_limit = Some(width.try_into().unwrap());
Copy link
Owner

Choose a reason for hiding this comment

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

Since .try_into() may fail, and .width_limit is an option anyway, we should let the failure become None rather than possibly panicking:

fmt.width_limit = width.try_into().ok();

crossterm::ErrorKind::IoError(e) => e,
_ => io::Error::new(io::ErrorKind::Other, msg),
}
fn map_xterm_err(xtermerr: crossterm::ErrorKind, _msg: &str) -> io::Error {
Copy link
Owner

Choose a reason for hiding this comment

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

Could you please add a TODO item to remove this function. (or remove it if you want)

@@ -384,67 +386,68 @@ fn do_read<D>(

let ev = interface.read_until(STOPEVENTS)?;

match (ev, verbatim_mode) {
Copy link
Owner

Choose a reason for hiding this comment

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

Is there a particular reason to not use match syntax? I find it more readable than if else expressions.

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.

2 participants