Skip to content

Remove origin primary #262

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

Merged
merged 2 commits into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,6 @@ impl Renderer {
max_line_num_len + 1,
);
}
Some(Element::Origin(origin)) if origin.primary => self
.draw_col_separator_end(
&mut buffer,
current_line,
max_line_num_len + 1,
),
None if group_len > 1 => self.draw_col_separator_end(
&mut buffer,
current_line,
Expand Down Expand Up @@ -386,6 +380,7 @@ impl Renderer {
&mut buffer,
max_line_num_len,
origin,
is_primary,
buffer_msg_line_offset,
);
last_was_suggestion = false;
Expand Down Expand Up @@ -472,7 +467,6 @@ impl Renderer {

if let Some(path) = &cause.path {
let mut origin = Origin::path(path.as_ref());
origin.primary = true;

let source_map = SourceMap::new(&cause.source, cause.line_start);
let (_depth, annotated_lines) =
Expand All @@ -493,7 +487,7 @@ impl Renderer {
}
}

self.render_origin(&mut buffer, 0, &origin, 0);
self.render_origin(&mut buffer, 0, &origin, true, 0);
buffer.append(0, ": ", ElementStyle::LineAndColumn);
}
}
Expand Down Expand Up @@ -641,9 +635,10 @@ impl Renderer {
buffer: &mut StyledBuffer,
max_line_num_len: usize,
origin: &Origin<'_>,
is_primary: bool,
buffer_msg_line_offset: usize,
) {
if origin.primary && !self.short_message {
if is_primary && !self.short_message {
buffer.prepend(
buffer_msg_line_offset,
self.file_start(),
Expand Down Expand Up @@ -712,7 +707,6 @@ impl Renderer {
//let is_primary = primary_path == Some(&origin.path);

if is_primary {
origin.primary = true;
if let Some(primary_line) = annotated_lines
.iter()
.find(|l| l.annotations.iter().any(LineAnnotation::is_primary))
Expand Down Expand Up @@ -752,7 +746,13 @@ impl Renderer {
}
}
let buffer_msg_line_offset = buffer.num_lines();
self.render_origin(buffer, max_line_num_len, &origin, buffer_msg_line_offset);
self.render_origin(
buffer,
max_line_num_len,
&origin,
is_primary,
buffer_msg_line_offset,
);
// Put in the spacer between the location and annotated source
self.draw_col_separator_no_space(
buffer,
Expand Down
8 changes: 0 additions & 8 deletions src/snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ pub struct Origin<'a> {
pub(crate) path: Cow<'a, str>,
pub(crate) line: Option<usize>,
pub(crate) char_column: Option<usize>,
pub(crate) primary: bool,
}

impl<'a> Origin<'a> {
Expand All @@ -453,7 +452,6 @@ impl<'a> Origin<'a> {
path: path.into(),
line: None,
char_column: None,
primary: false,
}
}

Expand All @@ -474,12 +472,6 @@ impl<'a> Origin<'a> {
self.char_column = Some(char_column);
self
}

/// Mark this as the source that the [Group's Title][Group::with_title] references
pub fn primary(mut self, primary: bool) -> Self {
self.primary = primary;
self
}
}

impl<'a> From<Cow<'a, str>> for Origin<'a> {
Expand Down
2 changes: 1 addition & 1 deletion tests/color/multiline_removal_suggestion.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading