Skip to content

Commit

Permalink
fix: before_ext should exclude directories since only files have ex…
Browse files Browse the repository at this point in the history
…tensions (#2132)
  • Loading branch information
sxyazi authored Dec 31, 2024
1 parent 00e8adc commit ef599a1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 38 deletions.
48 changes: 24 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ strip = true

[workspace.dependencies]
ansi-to-tui = "7.0.0"
anyhow = "1.0.94"
anyhow = "1.0.95"
base64 = "0.22.1"
bitflags = "2.6.0"
clap = { version = "4.5.23", features = [ "derive" ] }
Expand All @@ -26,8 +26,8 @@ parking_lot = "0.12.3"
ratatui = { version = "0.29.0", features = [ "unstable-rendered-line-info" ] }
regex = "1.11.1"
scopeguard = "1.2.0"
serde = { version = "1.0.216", features = [ "derive" ] }
serde_json = "1.0.133"
serde = { version = "1.0.217", features = [ "derive" ] }
serde_json = "1.0.134"
shell-words = "1.1.0"
tokio = { version = "1.42.0", features = [ "full" ] }
tokio-stream = "0.1.17"
Expand Down
4 changes: 2 additions & 2 deletions yazi-codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ proc-macro = true

[dependencies]
# External dependencies
syn = { version = "2.0.90", features = [ "full" ] }
quote = "1.0.37"
syn = { version = "2.0.93", features = [ "full" ] }
quote = "1.0.38"
17 changes: 8 additions & 9 deletions yazi-core/src/manager/commands/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,21 @@ impl Manager {
return self.bulk_rename();
}

let Some(hovered) = self.hovered().map(|h| h.url_owned()) else {
return;
};

let name = Self::empty_url_part(&hovered, &opt.empty);
let Some(hovered) = self.hovered() else { return };
let name = Self::empty_url_part(&hovered.url, &opt.empty);
let cursor = match opt.cursor.as_ref() {
"start" => Some(0),
"before_ext" => name
.chars()
.rev()
.position(|c| c == '.')
.filter(|_| !hovered.is_dir())
.map(|i| name.chars().count() - i - 1)
.filter(|&i| i != 0),
_ => None,
};

let old = hovered.url_owned();
let tab = self.tabs.active().id;
tokio::spawn(async move {
let mut result = InputProxy::show(InputCfg::rename().with_value(name).with_cursor(cursor));
Expand All @@ -64,11 +63,11 @@ impl Manager {
return;
}

let new = Url::from(hovered.parent().unwrap().join(name));
if opt.force || !maybe_exists(&new).await || paths_to_same_file(&hovered, &new).await {
Self::rename_do(tab, hovered, new).await.ok();
let new = Url::from(old.parent().unwrap().join(name));
if opt.force || !maybe_exists(&new).await || paths_to_same_file(&old, &new).await {
Self::rename_do(tab, old, new).await.ok();
} else if ConfirmProxy::show(ConfirmCfg::overwrite(&new)).await {
Self::rename_do(tab, hovered, new).await.ok();
Self::rename_do(tab, old, new).await.ok();
}
});
}
Expand Down

0 comments on commit ef599a1

Please sign in to comment.