浏览代码

patch the error of command mode (#35)

laokengwt 5 月之前
父节点
当前提交
29c3de33d3
共有 3 个文件被更改,包括 8 次插入8 次删除
  1. 2 2
      src/application/handler/app.rs
  2. 3 3
      src/application/handler/command.rs
  3. 3 3
      src/application/mod.rs

+ 2 - 2
src/application/handler/app.rs

@@ -40,12 +40,12 @@ pub fn to_workspace_mode(app: &mut Application) -> Result<()> {
 
 pub fn to_command_mode(app: &mut Application) -> Result<()> {
     app.switch_mode(ModeKey::Command);
-    OK(())
+    Ok(())
 }
 
 pub fn to_search_mode(app: &mut Application) -> Result<()> {
     app.switch_mode(ModeKey::Search);
-    OK(())
+    Ok(())
 }
 
 pub fn to_delete_mode(app: &mut Application) -> Result<()> {

+ 3 - 3
src/application/handler/command.rs

@@ -3,7 +3,7 @@ use std::collections::HashMap;
 use crossterm::event::KeyCode;
 use smallvec::SmallVec;
 
-use crate::application::handler::{app, workspace};
+use crate::application::handler::{app, buffer};
 use crate::application::mode::{ModeData, ModeKey};
 use crate::application::Application;
 use crate::errors::*;
@@ -28,13 +28,13 @@ lazy_static! {
         cmd_map.insert(
             "w".to_string(),
             SmallVec::from_vec(vec![
-                workspace::save_file as fn(&mut Application) -> Result<()>,
+                buffer::save_file as fn(&mut Application) -> Result<()>,
             ]),
         );
         cmd_map.insert(
             "wq".to_string(),
             SmallVec::from_vec(vec![
-                workspace::save_file as fn(&mut Application) -> Result<()>,
+                buffer::save_file as fn(&mut Application) -> Result<()>,
                 app::exit as fn(&mut Application) -> Result<()>,
             ]),
         );

+ 3 - 3
src/application/mod.rs

@@ -6,7 +6,8 @@ use crate::{
 use crossterm::{event::Event, terminal::disable_raw_mode};
 use held_core::plugin::Plugin;
 use mode::{
-    command::CommandData, error::ErrorRenderer, workspace::WorkspaceModeData, ModeData, ModeKey, search::SearchData, ModeRenderer, ModeRouter
+    command::CommandData, error::ErrorRenderer, search::SearchData, workspace::WorkspaceModeData,
+    ModeData, ModeKey, ModeRenderer, ModeRouter,
 };
 use smallvec::SmallVec;
 use state::ApplicationStateData;
@@ -117,10 +118,9 @@ impl Application {
             )?),
         );
         self.mode_history.insert(ModeKey::Delete, ModeData::Delete);
-
-        Ok(())
         self.mode_history
             .insert(ModeKey::Search, ModeData::Search(SearchData::new()));
+        Ok(())
     }
 
     pub fn run(&mut self) -> Result<()> {