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

Add replace tabs with spaces option #82

Merged
merged 5 commits into from
Oct 4, 2021
Merged

Conversation

jlkiri
Copy link
Contributor

@jlkiri jlkiri commented Oct 3, 2021

Closes #73

Makes it possible to replace tabs with spaces. This is needed because highlight line renderers are not aware of displayed tab width and appear in wrong places if line contains tabs.

README.md Outdated
@@ -389,6 +389,7 @@ miette::set_hook(Box::new(|_| {
.terminal_links(true)
.unicode(false)
.context_lines(3)
.with_tab_width(4)
Copy link
Owner

Choose a reason for hiding this comment

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

this should be just .tab_width

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done cb073dd

}
}

/// Replace tabs with spaces.
pub fn with_tab_width(mut self, width: usize) -> Self {
Copy link
Owner

Choose a reason for hiding this comment

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

You need to expose .tab_width() through MietteHandler, too, since that's the recommended way of customizing your handler in general.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done cb073dd

@@ -30,7 +30,6 @@ impl miette::ReportHandler for LocationHandler {
}

fn track_caller(&mut self, location: &'static Location<'static>) {
dbg!(location);
Copy link
Owner

Choose a reason for hiding this comment

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

oops! :P

@jlkiri jlkiri requested a review from zkat October 4, 2021 05:55
@@ -25,6 +25,7 @@ pub struct GraphicalReportHandler {
pub(crate) theme: GraphicalTheme,
pub(crate) footer: Option<String>,
pub(crate) context_lines: usize,
pub(crate) tab_width: Option<usize>,
Copy link

Choose a reason for hiding this comment

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

This might sound dumb, but I wonder if a user should be allowed to use tab_width = 0 for no space or it'd rather be better if tab_width = 0 means using tabs 🤔

@zkat zkat merged commit 6a79cb1 into zkat:main Oct 4, 2021
zkat pushed a commit that referenced this pull request Oct 6, 2021
zkat pushed a commit that referenced this pull request Oct 6, 2021
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.

Weird tab character rendering
3 participants