Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: Remove specialized code for item attributes#325

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
epage merged 1 commit intorust-lang:masterfromMuscraft:remove-attribute-code
Oct 22, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
36 changes: 1 addition & 35 deletionssrc/renderer/render.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1512,21 +1512,13 @@ fn emit_suggestion_default(
}
row_num += line_end.line - line_start.line;
}
let mut last_pos = 0;
let mut is_item_attribute = false;
let mut unhighlighted_lines = Vec::new();
for (line_pos, (line, highlight_parts)) in lines.by_ref().zip(highlights).enumerate() {
last_pos = line_pos;

// Remember lines that are not highlighted to hide them if needed
if highlight_parts.is_empty() && suggestion.fold {
unhighlighted_lines.push((line_pos, line));
continue;
}
if highlight_parts.len() == 1 && line.trim().starts_with("#[") && line.trim().ends_with(']')
{
is_item_attribute = true;
}

match unhighlighted_lines.len() {
0 => (),
Expand DownExpand Up@@ -1614,32 +1606,6 @@ fn emit_suggestion_default(
);
}

if matches!(show_code_change, DisplaySuggestion::Add) && is_item_attribute {
// The suggestion adds an entire line of code, ending on a newline, so we'll also
// print the *following* line, to provide context of what we're advising people to
// do. Otherwise you would only see contextless code that can be confused for
// already existing code, despite the colors and UI elements.
// We special case `#[derive(_)]\n` and other attribute suggestions, because those
// are the ones where context is most useful.
let file_lines = sm.span_to_lines(parts[0].span.end..parts[0].span.end);
let (lo, _) = sm.span_to_locations(parts[0].span.clone());
let line_num = lo.line;
if let Some(line) = sm.get_line(line_num) {
let line = normalize_whitespace(line);
draw_code_line(
renderer,
buffer,
&mut row_num,
&[],
line_num + last_pos + 1,
&line,
DisplaySuggestion::None,
max_line_num_len,
&file_lines,
is_multiline,
);
}
}
// This offset and the ones below need to be signed to account for replacement code
// that is shorter than the original code.
let mut offsets: Vec<(usize, isize)> = Vec::new();
Expand DownExpand Up@@ -1929,7 +1895,7 @@ fn draw_code_line(
[SubstitutionHighlight { start: 0, end }] if *end == line_to_add.len() => {
buffer.puts(*row_num, max_line_num_len + 1, "+ ", ElementStyle::Addition);
}
[] => {
[]| [SubstitutionHighlight { start: 0, end: 0 }]=> {
// FIXME: needed? Doesn't get exercised in any test.
draw_col_separator_no_space(renderer, buffer, *row_num, max_line_num_len + 1);
}
Expand Down
4 changes: 2 additions & 2 deletionstests/formatter.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4869,7 +4869,7 @@ help: consider importing this module
|
1 |
2 + use std::cell;
3~ use st::cell::Cell;
3| use st::cell::Cell;
4 |
5 | mod bar {
6 | pub fn bar() { bar::baz(); }
Expand DownExpand Up@@ -4900,7 +4900,7 @@ help: consider importing this module
╭╴
1 │
2 + use std::cell;
3± use st::cell::Cell;
3 use st::cell::Cell;
4 │
5 │ mod bar {
6 │ pub fn bar() { bar::baz(); }
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp