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

Commit c08abcc

Browse files
fix: Fix double mistake in EndLine
EndLine::Crlf and EndLine::Lf had wrong lengths, and all usages of them were also flipped. Both issues happened to cancel out. This commit fixes both, and so this should be a no-op.
1 parent c84e388 commit c08abcc

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

‎src/renderer/display_list.rs‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -940,9 +940,20 @@ impl<'a> CursorLines<'a> {
940940

941941
#[derive(Copy, Clone, Debug, PartialEq)]
942942
pub(crate) enum EndLine {
943-
Eof = 0,
944-
Crlf = 1,
945-
Lf = 2,
943+
Eof,
944+
Lf,
945+
Crlf,
946+
}
947+
948+
impl EndLine {
949+
/// The number of characters this line ending occupies in bytes.
950+
pub(crate) fn len(self) -> usize {
951+
match self {
952+
EndLine::Eof => 0,
953+
EndLine::Lf => 1,
954+
EndLine::Crlf => 2,
955+
}
956+
}
946957
}
947958

948959
impl<'a> Iterator for CursorLines<'a> {
@@ -957,12 +968,12 @@ impl<'a> Iterator for CursorLines<'a> {
957968
.map(|x| {
958969
let ret = if 0 < x {
959970
if self.0.as_bytes()[x - 1] == b'\r' {
960-
(&self.0[..x - 1], EndLine::Lf)
971+
(&self.0[..x - 1], EndLine::Crlf)
961972
} else {
962-
(&self.0[..x], EndLine::Crlf)
973+
(&self.0[..x], EndLine::Lf)
963974
}
964975
} else {
965-
("", EndLine::Crlf)
976+
("", EndLine::Lf)
966977
};
967978
self.0 = &self.0[x + 1..];
968979
ret
@@ -1138,7 +1149,7 @@ fn format_header<'a>(
11381149
..
11391150
} = item
11401151
{
1141-
if main_range >= range.0 && main_range <= range.1 + *end_lineasusize {
1152+
if main_range >= range.0 && main_range <= range.1 + end_line.len() {
11421153
let char_column = text[0..(main_range - range.0).min(text.len())]
11431154
.chars()
11441155
.count();
@@ -1366,7 +1377,7 @@ fn format_body(
13661377
for (idx, (line, end_line)) in CursorLines::new(snippet.source).enumerate() {
13671378
let line_length: usize = line.len();
13681379
let line_range = (current_index, current_index + line_length);
1369-
let end_line_size = end_lineasusize;
1380+
let end_line_size = end_line.len();
13701381
body.push(DisplayLine::Source {
13711382
lineno: Some(current_line),
13721383
inline_marks: vec![],

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /