Don't use TabMap::expand_tabs in line_indent_for_buffer_row
This commit is contained in:
parent
08e93e9321
commit
5c1f82ae3d
3 changed files with 13 additions and 16 deletions
|
@ -634,24 +634,21 @@ impl DisplaySnapshot {
|
||||||
.buffer_snapshot
|
.buffer_snapshot
|
||||||
.buffer_line_for_row(buffer_row)
|
.buffer_line_for_row(buffer_row)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let chars = buffer.chars_at(Point::new(range.start.row, 0));
|
|
||||||
|
|
||||||
|
let mut indent_size = 0;
|
||||||
let mut is_blank = false;
|
let mut is_blank = false;
|
||||||
let indent_size = self.tab_snapshot.expand_tabs(
|
for c in buffer.chars_at(Point::new(range.start.row, 0)) {
|
||||||
chars.take_while(|c| {
|
if c == ' ' || c == '\t' {
|
||||||
if *c == ' ' || *c == '\t' {
|
indent_size += 1;
|
||||||
true
|
} else {
|
||||||
} else {
|
if c == '\n' {
|
||||||
if *c == '\n' {
|
is_blank = true;
|
||||||
is_blank = true;
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}),
|
break;
|
||||||
buffer.line_len(buffer_row), // Never collapse
|
}
|
||||||
);
|
}
|
||||||
|
|
||||||
(indent_size as u32, is_blank)
|
(indent_size, is_blank)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn line_len(&self, row: u32) -> u32 {
|
pub fn line_len(&self, row: u32) -> u32 {
|
||||||
|
|
|
@ -290,7 +290,7 @@ impl TabSnapshot {
|
||||||
fold_point.to_buffer_point(&self.suggestion_snapshot.fold_snapshot)
|
fold_point.to_buffer_point(&self.suggestion_snapshot.fold_snapshot)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expand_tabs(&self, chars: impl Iterator<Item = char>, column: u32) -> u32 {
|
fn expand_tabs(&self, chars: impl Iterator<Item = char>, column: u32) -> u32 {
|
||||||
let tab_size = self.tab_size.get();
|
let tab_size = self.tab_size.get();
|
||||||
|
|
||||||
let mut expanded_chars = 0;
|
let mut expanded_chars = 0;
|
||||||
|
|
|
@ -630,7 +630,7 @@ fn test_cancel(cx: &mut gpui::MutableAppContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_fold(cx: &mut gpui::MutableAppContext) {
|
fn test_fold_action(cx: &mut gpui::MutableAppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple(
|
let buffer = MultiBuffer::build_simple(
|
||||||
&"
|
&"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue