diff --git a/zed/src/editor/display_map/tab_map.rs b/zed/src/editor/display_map/tab_map.rs index 75049e40ca..fb11e08024 100644 --- a/zed/src/editor/display_map/tab_map.rs +++ b/zed/src/editor/display_map/tab_map.rs @@ -2,7 +2,7 @@ use parking_lot::Mutex; use super::fold_map::{self, FoldEdit, FoldPoint, Snapshot as FoldSnapshot}; use crate::{editor::rope, settings::StyleId, util::Bias}; -use std::{cmp, mem, ops::Range}; +use std::{mem, ops::Range}; pub struct TabMap(Mutex); @@ -36,8 +36,8 @@ impl TabMap { let patterns: &[_] = &['\t', '\n']; if let Some(ix) = chunk.find(patterns) { if &chunk[ix..ix + 1] == "\t" { - fold_edit.old_bytes.end.0 += delta + ix + old_snapshot.tab_size; - fold_edit.new_bytes.end.0 += delta + ix + new_snapshot.tab_size; + fold_edit.old_bytes.end.0 += delta + ix + 1; + fold_edit.new_bytes.end.0 += delta + ix + 1; } break; @@ -45,10 +45,6 @@ impl TabMap { delta += chunk.len(); } - fold_edit.old_bytes.end = - cmp::min(fold_edit.old_bytes.end, old_snapshot.fold_snapshot.len()); - fold_edit.new_bytes.end = - cmp::min(fold_edit.new_bytes.end, new_snapshot.fold_snapshot.len()); } let mut ix = 1; diff --git a/zed/src/editor/display_map/wrap_map.rs b/zed/src/editor/display_map/wrap_map.rs index 68a649ff0d..d2f38971a8 100644 --- a/zed/src/editor/display_map/wrap_map.rs +++ b/zed/src/editor/display_map/wrap_map.rs @@ -902,6 +902,10 @@ mod tests { }); let (mut fold_map, folds_snapshot) = cx.read(|cx| FoldMap::new(buffer.clone(), cx)); let (tab_map, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), settings.tab_size); + log::info!( + "Unwrapped text (no folds): {:?}", + buffer.read_with(&cx, |buf, _| buf.text()) + ); log::info!( "Unwrapped text (unexpanded tabs): {:?}", folds_snapshot.text() @@ -957,6 +961,10 @@ mod tests { } } + log::info!( + "Unwrapped text (no folds): {:?}", + buffer.read_with(&cx, |buf, _| buf.text()) + ); let (folds_snapshot, edits) = cx.read(|cx| fold_map.read(cx)); log::info!( "Unwrapped text (unexpanded tabs): {:?}",