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

Show correct line numbers when fold ist set to true, fixes #52#55

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
zbraniecki merged 1 commit intorust-lang:masterfromInky-developer:fix-52
Jun 2, 2023
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
12 changes: 6 additions & 6 deletionssrc/display_list/from_snippet.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -111,10 +111,9 @@ fn format_slice(
) -> Vec<DisplayLine<'_>> {
let main_range = slice.annotations.get(0).map(|x| x.range.0);
let origin = slice.origin;
let line_start = slice.line_start;
let need_empty_header = origin.is_some() || is_first;
let mut body = format_body(slice, need_empty_header, has_footer, margin);
let header = format_header(origin, main_range,line_start,&body, is_first);
let header = format_header(origin, main_range, &body, is_first);
let mut result = vec![];

if let Some(header) = header {
Expand All@@ -133,7 +132,6 @@ fn zip_opt<A, B>(a: Option<A>, b: Option<B>) -> Option<(A, B)> {
fn format_header<'a>(
origin: Option<&'a str>,
main_range: Option<usize>,
mut row: usize,
body: &[DisplayLine<'_>],
is_first: bool,
) -> Option<DisplayLine<'a>> {
Expand All@@ -145,24 +143,26 @@ fn format_header<'a>(

if let Some((main_range, path)) = zip_opt(main_range, origin) {
let mut col = 1;
let mut line_offset = 1;

for item in body {
if let DisplayLine::Source {
line: DisplaySourceLine::Content { range, .. },
lineno,
..
} = item
{
if main_range >= range.0 && main_range <= range.1 {
col = main_range - range.0 + 1;
line_offset = lineno.unwrap_or(1);
break;
}
row += 1;
}
}

return Some(DisplayLine::Raw(DisplayRawLine::Origin {
path,
pos: Some((row, col)),
pos: Some((line_offset, col)),
header_type: display_header,
}));
}
Expand DownExpand Up@@ -307,7 +307,7 @@ fn format_body(
let char_widths = line
.chars()
.map(|c| unicode_width::UnicodeWidthChar::width(c).unwrap_or(0))
.chain(std::iter::once(1)) // treat the end of line assignle-width
.chain(std::iter::once(1)) // treat the end of line assingle-width
.collect::<Vec<_>>();
body.push(DisplayLine::Source {
lineno: Some(current_line),
Expand Down
16 changes: 16 additions & 0 deletionstests/fixtures/no-color/issue_52.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
[title]
annotation_type = "Error"

[[slices]]
source = """


invalid syntax
"""
line_start = 1
origin = "path/to/error.rs"
fold = true
[[slices.annotations]]
label = "error here"
annotation_type = "Warning"
range = [2,16]
7 changes: 7 additions & 0 deletionstests/fixtures/no-color/issue_52.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
error
--> path/to/error.rs:3:1
|
...
3 | invalid syntax
| -------------- error here
|

[8]ページ先頭

©2009-2025 Movatter.jp