Implement = (equalize/auto-indent) verb, fix dedent indexing, remove unimplemented screen-line motions, and clean up unreachable match arms

This commit is contained in:
2026-03-16 23:31:54 -04:00
parent db3f1b5108
commit ac8940f936
12 changed files with 244 additions and 229 deletions

View File

@@ -154,13 +154,13 @@ impl ViMode for ViEx {
None
}
fn editor(&mut self) -> Option<&mut LineBuf> {
Some(&mut self.pending_cmd.buf)
}
fn editor(&mut self) -> Option<&mut LineBuf> {
Some(&mut self.pending_cmd.buf)
}
fn history(&mut self) -> Option<&mut History> {
Some(&mut self.pending_cmd.history)
}
fn history(&mut self) -> Option<&mut History> {
Some(&mut self.pending_cmd.history)
}
fn cursor_style(&self) -> String {
"\x1b[3 q".to_string()
@@ -338,13 +338,13 @@ fn parse_read(chars: &mut Peekable<Chars<'_>>) -> Result<Option<Verb>, Option<St
}
fn get_path(path: &str) -> Result<PathBuf, Option<String>> {
log::debug!("Expanding path: {}", path);
log::debug!("Expanding path: {}", path);
let expanded = Expander::from_raw(path, TkFlags::empty())
.map_err(|e| Some(format!("Error expanding path: {}", e)))?
.expand()
.expand()
.map_err(|e| Some(format!("Error expanding path: {}", e)))?
.join(" ");
log::debug!("Expanded path: {}", expanded);
.join(" ");
log::debug!("Expanded path: {}", expanded);
Ok(PathBuf::from(&expanded))
}

View File

@@ -81,9 +81,15 @@ pub trait ViMode {
fn as_replay(&self) -> Option<CmdReplay>;
fn cursor_style(&self) -> String;
fn pending_seq(&self) -> Option<String>;
fn pending_cursor(&self) -> Option<usize> { None }
fn editor(&mut self) -> Option<&mut LineBuf> { None }
fn history(&mut self) -> Option<&mut History> { None }
fn pending_cursor(&self) -> Option<usize> {
None
}
fn editor(&mut self) -> Option<&mut LineBuf> {
None
}
fn history(&mut self) -> Option<&mut History> {
None
}
fn move_cursor_on_undo(&self) -> bool;
fn clamp_cursor(&self) -> bool;
fn hist_scroll_start_pos(&self) -> Option<To>;

View File

@@ -450,26 +450,10 @@ impl ViNormal {
Motion::WordMotion(To::End, Word::Big, Direction::Backward),
));
}
'k' => {
chars = chars_clone;
break 'motion_parse Some(MotionCmd(count, Motion::ScreenLineUp));
}
'j' => {
chars = chars_clone;
break 'motion_parse Some(MotionCmd(count, Motion::ScreenLineDown));
}
'_' => {
chars = chars_clone;
break 'motion_parse Some(MotionCmd(count, Motion::EndOfLastWord));
}
'0' => {
chars = chars_clone;
break 'motion_parse Some(MotionCmd(count, Motion::BeginningOfScreenLine));
}
'^' => {
chars = chars_clone;
break 'motion_parse Some(MotionCmd(count, Motion::FirstGraphicalOnScreenLine));
}
_ => return self.quit_parse(),
}
}

View File

@@ -376,16 +376,6 @@ impl ViVisual {
Motion::WordMotion(To::End, Word::Big, Direction::Backward),
));
}
'k' => {
chars_clone.next();
chars = chars_clone;
break 'motion_parse Some(MotionCmd(count, Motion::ScreenLineUp));
}
'j' => {
chars_clone.next();
chars = chars_clone;
break 'motion_parse Some(MotionCmd(count, Motion::ScreenLineDown));
}
_ => return self.quit_parse(),
}
} else {