summaryrefslogtreecommitdiffstats
path: root/src/event_exec.rs
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2023-10-22 23:15:31 +0200
committerqkzk <qu3nt1n@gmail.com>2023-10-22 23:15:31 +0200
commit920adf620455274bee7b7e39c46223c44749a825 (patch)
treed1d314e72690f9b8b96213e2c705aaf365e9ce5e /src/event_exec.rs
parent22ee632f9da1cd7a3f535abafe09256f4bd401bf (diff)
Move cursor 1 char right in input. Use unicode segmentation when replacing input
Diffstat (limited to 'src/event_exec.rs')
-rw-r--r--src/event_exec.rs25
1 files changed, 4 insertions, 21 deletions
diff --git a/src/event_exec.rs b/src/event_exec.rs
index 91d1fce..eff4b91 100644
--- a/src/event_exec.rs
+++ b/src/event_exec.rs
@@ -38,8 +38,8 @@ use crate::status::Status;
use crate::tab::Tab;
use crate::utils::is_program_in_path;
use crate::utils::{
- args_is_empty, disk_used_by_path, filename_from_path, is_sudo_command, open_in_current_neovim,
- opt_mount_point, string_to_path,
+ args_is_empty, disk_used_by_path, is_sudo_command, open_in_current_neovim, opt_mount_point,
+ string_to_path,
};
/// Links events from tuikit to custom actions.
@@ -358,21 +358,7 @@ impl EventAction {
/// When we enter rename from a "tree" mode, we'll need to rename the selected file in the tree,
/// not the selected file in the pathcontent.
pub fn rename(tab: &mut Tab) -> Result<()> {
- if tab.selected().is_some() {
- let old_name = match tab.mode {
- Mode::Tree => tab.directory.tree.current_node.filename(),
- _ => filename_from_path(
- &tab.path_content
- .selected()
- .context("Event rename: no file in current directory")?
- .path,
- )?
- .to_owned(),
- };
- tab.input.replace(&old_name);
- tab.set_mode(Mode::InputSimple(InputSimple::Rename));
- }
- Ok(())
+ tab.rename()
}
/// Enter the goto mode where an user can type a path to jump to.
@@ -635,10 +621,7 @@ impl EventAction {
pub fn delete(status: &mut Status) -> Result<()> {
match status.selected().mode {
Mode::InputSimple(_) | Mode::InputCompleted(_) => {
- {
- let tab: &mut Tab = status.selected();
- tab.input.delete_chars_right()
- };
+ status.selected().input.delete_chars_right();
Ok(())
}
_ => Ok(()),