-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: using definite patterns to simplify keybindings (#690)
- Loading branch information
Showing
23 changed files
with
167 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use yazi_shared::event::Cmd; | ||
|
||
use crate::tab::Tab; | ||
|
||
impl Tab { | ||
pub fn back(&mut self, _: Cmd) { self.backstack.shift_backward().cloned().map(|u| self.cd(u)); } | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,9 @@ | ||
use std::mem; | ||
use yazi_shared::event::Cmd; | ||
|
||
use yazi_shared::{event::Cmd, render}; | ||
|
||
use crate::{manager::Manager, tab::Tab}; | ||
|
||
pub struct Opt; | ||
impl From<()> for Opt { | ||
fn from(_: ()) -> Self { Self } | ||
} | ||
impl From<Cmd> for Opt { | ||
fn from(_: Cmd) -> Self { Self } | ||
} | ||
use crate::tab::Tab; | ||
|
||
impl Tab { | ||
pub fn enter(&mut self, _: impl Into<Opt>) { | ||
let Some(hovered) = self.current.hovered().filter(|h| h.is_dir()).map(|h| h.url()) else { | ||
return; | ||
}; | ||
|
||
// Current | ||
let rep = self.history_new(&hovered); | ||
let rep = mem::replace(&mut self.current, rep); | ||
if rep.cwd.is_regular() { | ||
self.history.insert(rep.cwd.clone(), rep); | ||
} | ||
|
||
// Parent | ||
if let Some(rep) = self.parent.take() { | ||
self.history.insert(rep.cwd.clone(), rep); | ||
} | ||
self.parent = Some(self.history_new(&hovered.parent_url().unwrap())); | ||
|
||
// Backstack | ||
self.backstack.push(hovered); | ||
|
||
Manager::_refresh(); | ||
render!(); | ||
pub fn enter(&mut self, _: Cmd) { | ||
self.current.hovered().filter(|h| h.is_dir()).map(|h| h.url()).map(|u| self.cd(u)); | ||
} | ||
} |
Oops, something went wrong.