fix sqlez warning, introduce tab and enter bindings to vim for inputing tab and enter text when waiting for text

This commit is contained in:
Kay Simmons 2023-02-10 15:41:19 -08:00
parent 3d53336916
commit 459060764a
3 changed files with 21 additions and 18 deletions

View File

@ -315,7 +315,8 @@
{
"context": "Editor && VimWaiting",
"bindings": {
// "*": "gpui::KeyPressed",
"tab": "vim::Tab",
"enter": "vim::Enter",
"escape": "editor::Cancel"
}
}

View File

@ -83,7 +83,6 @@ impl Connection {
#[cfg(test)]
mod test {
use indoc::indoc;
use sqlez_macros::sql;
use crate::connection::Connection;
@ -288,21 +287,18 @@ mod test {
let connection = Connection::open_memory(Some("test_create_alter_drop"));
connection
.migrate(
"first_migration",
&[sql!( CREATE TABLE table1(a TEXT) STRICT; )],
)
.migrate("first_migration", &["CREATE TABLE table1(a TEXT) STRICT;"])
.unwrap();
connection
.exec(sql!( INSERT INTO table1(a) VALUES ("test text"); ))
.exec("INSERT INTO table1(a) VALUES (\"test text\");")
.unwrap()()
.unwrap();
connection
.migrate(
"second_migration",
&[sql!(
&[indoc! {"
CREATE TABLE table2(b TEXT) STRICT;
INSERT INTO table2 (b)
@ -311,16 +307,11 @@ mod test {
DROP TABLE table1;
ALTER TABLE table2 RENAME TO table1;
)],
"}],
)
.unwrap();
let res = &connection
.select::<String>(sql!(
SELECT b FROM table1
))
.unwrap()()
.unwrap()[0];
let res = &connection.select::<String>("SELECT b FROM table1").unwrap()().unwrap()[0];
assert_eq!(res, "test text");
}

View File

@ -15,7 +15,7 @@ use std::sync::Arc;
use command_palette::CommandPaletteFilter;
use editor::{Bias, Cancel, Editor, EditorMode};
use gpui::{
impl_actions, MutableAppContext, Subscription, ViewContext, ViewHandle, WeakViewHandle,
actions, impl_actions, MutableAppContext, Subscription, ViewContext, ViewHandle, WeakViewHandle,
};
use language::CursorShape;
use motion::Motion;
@ -35,6 +35,7 @@ pub struct PushOperator(pub Operator);
#[derive(Clone, Deserialize, PartialEq)]
struct Number(u8);
actions!(vim, [Tab, Enter]);
impl_actions!(vim, [Number, SwitchMode, PushOperator]);
pub fn init(cx: &mut MutableAppContext) {
@ -74,8 +75,16 @@ pub fn init(cx: &mut MutableAppContext) {
}
});
cx.add_action(|_: &mut Workspace, _: &Tab, cx| {
Vim::active_editor_input_ignored(" ".into(), cx)
});
cx.add_action(|_: &mut Workspace, _: &Enter, cx| {
Vim::active_editor_input_ignored("\n".into(), cx)
});
// Sync initial settings with the rest of the app
Vim::update(cx, |state, cx| state.sync_vim_settings(cx));
Vim::update(cx, |vim, cx| vim.sync_vim_settings(cx));
// Any time settings change, update vim mode to match
cx.observe_global::<Settings, _>(|cx| {
@ -99,7 +108,9 @@ pub fn observe_keystrokes(window_id: usize, cx: &mut MutableAppContext) {
}
Vim::update(cx, |vim, cx| match vim.active_operator() {
Some(Operator::FindForward { .. } | Operator::FindBackward { .. }) => {}
Some(
Operator::FindForward { .. } | Operator::FindBackward { .. } | Operator::Replace,
) => {}
Some(_) => {
vim.clear_operator(cx);
}