Fix vim selection to include entire range

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
Conrad Irwin 2023-07-24 23:59:37 -06:00
parent e6f3e0ab9c
commit b53fb8633e
21 changed files with 489 additions and 335 deletions

View file

@ -1,3 +1,4 @@
use editor::display_map::Clip;
use gpui::keymap_matcher::KeymapContext;
use language::CursorShape;
use serde::{Deserialize, Serialize};
@ -12,6 +13,15 @@ pub enum Mode {
Visual { line: bool },
}
impl Mode {
pub fn is_visual(&self) -> bool {
match self {
Mode::Normal | Mode::Insert => false,
Mode::Visual { .. } => true,
}
}
}
impl Default for Mode {
fn default() -> Self {
Self::Normal
@ -78,12 +88,11 @@ impl VimState {
)
}
pub fn clip_at_line_end(&self) -> bool {
!matches!(self.mode, Mode::Insert | Mode::Visual { .. })
}
pub fn empty_selections_only(&self) -> bool {
!matches!(self.mode, Mode::Visual { .. })
pub fn default_clip(&self) -> Clip {
match self.mode {
Mode::Insert | Mode::Visual { .. } => Clip::None,
Mode::Normal => Clip::EndOfLine,
}
}
pub fn keymap_context_layer(&self) -> KeymapContext {