refactor: Remove G/Z Namespace support
This previously enabled things like `d g g` to work, but we can fix that instead by not clearing out pending vim state on change. Either way, it is unnecessary and causes some user-confusion (zed-industries/community#176), so remove this code for now; and use comments to organize the file a bit instead.
This commit is contained in:
parent
35400d5797
commit
8ba69c15d1
5 changed files with 34 additions and 79 deletions
|
@ -127,9 +127,8 @@ pub fn init(cx: &mut AppContext) {
|
|||
}
|
||||
|
||||
pub(crate) fn motion(motion: Motion, cx: &mut WindowContext) {
|
||||
if let Some(Operator::Namespace(_))
|
||||
| Some(Operator::FindForward { .. })
|
||||
| Some(Operator::FindBackward { .. }) = Vim::read(cx).active_operator()
|
||||
if let Some(Operator::FindForward { .. }) | Some(Operator::FindBackward { .. }) =
|
||||
Vim::read(cx).active_operator()
|
||||
{
|
||||
Vim::update(cx, |vim, cx| vim.pop_operator(cx));
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ pub fn normal_motion(
|
|||
Some(Operator::Delete) => delete_motion(vim, motion, times, cx),
|
||||
Some(Operator::Yank) => yank_motion(vim, motion, times, cx),
|
||||
Some(operator) => {
|
||||
// Can't do anything for text objects or namespace operators. Ignoring
|
||||
// Can't do anything for text objects, Ignoring
|
||||
error!("Unexpected normal mode motion operator: {:?}", operator)
|
||||
}
|
||||
}
|
||||
|
@ -441,11 +441,8 @@ mod test {
|
|||
use indoc::indoc;
|
||||
|
||||
use crate::{
|
||||
state::{
|
||||
Mode::{self, *},
|
||||
Namespace, Operator,
|
||||
},
|
||||
test::{ExemptionFeatures, NeovimBackedTestContext, VimTestContext},
|
||||
state::Mode::{self, *},
|
||||
test::{ExemptionFeatures, NeovimBackedTestContext},
|
||||
};
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -610,22 +607,6 @@ mod test {
|
|||
.await;
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_g_prefix_and_abort(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = VimTestContext::new(cx, true).await;
|
||||
|
||||
// Can abort with escape to get back to normal mode
|
||||
cx.simulate_keystroke("g");
|
||||
assert_eq!(cx.mode(), Normal);
|
||||
assert_eq!(
|
||||
cx.active_operator(),
|
||||
Some(Operator::Namespace(Namespace::G))
|
||||
);
|
||||
cx.simulate_keystroke("escape");
|
||||
assert_eq!(cx.mode(), Normal);
|
||||
assert_eq!(cx.active_operator(), None);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_gg(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
|
|
@ -16,16 +16,9 @@ impl Default for Mode {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize)]
|
||||
pub enum Namespace {
|
||||
G,
|
||||
Z,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize)]
|
||||
pub enum Operator {
|
||||
Number(usize),
|
||||
Namespace(Namespace),
|
||||
Change,
|
||||
Delete,
|
||||
Yank,
|
||||
|
@ -126,8 +119,6 @@ impl Operator {
|
|||
pub fn id(&self) -> &'static str {
|
||||
match self {
|
||||
Operator::Number(_) => "n",
|
||||
Operator::Namespace(Namespace::G) => "g",
|
||||
Operator::Namespace(Namespace::Z) => "z",
|
||||
Operator::Object { around: false } => "i",
|
||||
Operator::Object { around: true } => "a",
|
||||
Operator::Change => "c",
|
||||
|
|
|
@ -14,7 +14,7 @@ use anyhow::Result;
|
|||
use collections::CommandPaletteFilter;
|
||||
use editor::{Bias, Editor, EditorMode, Event};
|
||||
use gpui::{
|
||||
actions, impl_actions, keymap_matcher::KeymapContext, AppContext, Subscription, ViewContext,
|
||||
actions, impl_actions,keymap_matcher::MatchResult, keymap_matcher::KeymapContext, AppContext, Subscription, ViewContext,
|
||||
ViewHandle, WeakViewHandle, WindowContext,
|
||||
};
|
||||
use language::CursorShape;
|
||||
|
@ -90,7 +90,10 @@ pub fn init(cx: &mut AppContext) {
|
|||
}
|
||||
|
||||
pub fn observe_keystrokes(cx: &mut WindowContext) {
|
||||
cx.observe_keystrokes(|_keystroke, _result, handled_by, cx| {
|
||||
cx.observe_keystrokes(|_keystroke, result, handled_by, cx| {
|
||||
if result == &MatchResult::Pending {
|
||||
return true;
|
||||
}
|
||||
if let Some(handled_by) = handled_by {
|
||||
// Keystroke is handled by the vim system, so continue forward
|
||||
if handled_by.namespace() == "vim" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue