vim: Fix relative line motion
Before this change up and down were in display co-ordinates, after this change they are in fold coordinates (which matches the vim behaviour). To make this work without causing usabliity problems, a bunch of extra keyboard shortcuts now work: - vim: `z {o,c}` to open,close a fold - vim: `z f` to fold current visual selection - vim: `g {j,k,up,down}` to move up/down a display line - vim: `g {0,^,$,home,end}` to get to start/end of a display line Fixes: zed-industries/community#1562
This commit is contained in:
parent
0280d5d010
commit
20aa2a4c54
13 changed files with 580 additions and 67 deletions
|
@ -30,6 +30,7 @@ pub use block_map::{
|
|||
BlockDisposition, BlockId, BlockProperties, BlockStyle, RenderBlock, TransformBlock,
|
||||
};
|
||||
|
||||
pub use self::fold_map::FoldPoint;
|
||||
pub use self::inlay_map::{Inlay, InlayOffset, InlayPoint};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
|
@ -310,7 +311,7 @@ impl DisplayMap {
|
|||
|
||||
pub struct DisplaySnapshot {
|
||||
pub buffer_snapshot: MultiBufferSnapshot,
|
||||
fold_snapshot: fold_map::FoldSnapshot,
|
||||
pub fold_snapshot: fold_map::FoldSnapshot,
|
||||
inlay_snapshot: inlay_map::InlaySnapshot,
|
||||
tab_snapshot: tab_map::TabSnapshot,
|
||||
wrap_snapshot: wrap_map::WrapSnapshot,
|
||||
|
@ -438,6 +439,20 @@ impl DisplaySnapshot {
|
|||
fold_point.to_inlay_point(&self.fold_snapshot)
|
||||
}
|
||||
|
||||
pub fn display_point_to_fold_point(&self, point: DisplayPoint, bias: Bias) -> FoldPoint {
|
||||
let block_point = point.0;
|
||||
let wrap_point = self.block_snapshot.to_wrap_point(block_point);
|
||||
let tab_point = self.wrap_snapshot.to_tab_point(wrap_point);
|
||||
self.tab_snapshot.to_fold_point(tab_point, bias).0
|
||||
}
|
||||
|
||||
pub fn fold_point_to_display_point(&self, fold_point: FoldPoint) -> DisplayPoint {
|
||||
let tab_point = self.tab_snapshot.to_tab_point(fold_point);
|
||||
let wrap_point = self.wrap_snapshot.tab_point_to_wrap_point(tab_point);
|
||||
let block_point = self.block_snapshot.to_block_point(wrap_point);
|
||||
DisplayPoint(block_point)
|
||||
}
|
||||
|
||||
pub fn max_point(&self) -> DisplayPoint {
|
||||
DisplayPoint(self.block_snapshot.max_point())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue