Skip to content

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

Open
NotGyro wants to merge 7 commits intokurtlawrence:masterfrom
forestcontact:master
Open

Fixed a rustfmt tab-related bug, updated dependencies and fixed breaking changes to their APIs#105
NotGyro wants to merge 7 commits intokurtlawrence:masterfrom
forestcontact:master

Conversation

@NotGyro
Copy link
Copy Markdown

@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
Copy Markdown
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.

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

Choose a reason for hiding this comment

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

Unnecessary parentheses

}
.saturating_sub(repl.prompt(false).chars().count());
fmt.width_limit = Some(width);
fmt.width_limit = Some(width.try_into().unwrap());
Copy link
Copy Markdown
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
Copy Markdown
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)


let ev = interface.read_until(STOPEVENTS)?;

match (ev, verbatim_mode) {
Copy link
Copy Markdown
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