Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: better handling of killing path separator #385

Closed
wants to merge 2 commits into from

Conversation

XOR-op
Copy link
Contributor

@XOR-op XOR-op commented Nov 21, 2023

Better handling of killing trailing path separator.

Example:

.config/yazi/ # original input
# press ctrl-w
.config/yazi  # w/o this PR
.config/      # w/ this PR

@sxyazi
Copy link
Owner

sxyazi commented Nov 23, 2023

Can we add it behind a parameter like kill forward --big-word?

@XOR-op XOR-op force-pushed the optimized-kill-path-separator branch from 780c55c to 117c14e Compare December 23, 2023 22:47
@XOR-op
Copy link
Contributor Author

XOR-op commented Dec 23, 2023

Sorry for the late update since I have a busy month. Now this behavior is controlled by the argument.

Self { kind: e.args.first().map(|s| s.as_str()).unwrap_or_default() }
Self {
kind: e.args.first().map(|s| s.as_str()).unwrap_or_default(),
mode: e.named.get("big-word").map_or(KillMode::Default, |_| KillMode::BigWord),
Copy link
Owner

@sxyazi sxyazi Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its better to impl the FromStr (also Default) trait for the KillMode to do this.

spaces + count_characters(input.skip(spaces))
let space_or_trailing_slash = match input.clone().next() {
Some(std::path::MAIN_SEPARATOR) if matches!(mode, KillMode::BigWord) => 1,
Some(c) if CharKind::new(c) == CharKind::Space => count_spaces(input.clone()),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that if CharKind::new(c) == CharKind::Space is unnecessary.

@sxyazi
Copy link
Owner

sxyazi commented May 16, 2024

I'm going to close this because it still needs some work and hasn't seen any activity recently. @XOR-op thanks for the effort!

@sxyazi sxyazi closed this May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants