Skip to content

Commit 91838f8

Browse files
committed
Fix symlink handling
- Broken symlink should display without error. - Display the symlink destination. - Fix deleting symlinks pointing to a directory. Fixes: #185
1 parent b86be16 commit 91838f8

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "xplr"
3-
version = "0.10.1" # Update lua.rs
3+
version = "0.10.2" # Update lua.rs
44
authors = ["Arijit Basu <[email protected]>"]
55
edition = "2018"
66
description = "A hackable, minimal, fast TUI file explorer"

src/init.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ xplr.config.modes.builtin.delete = {
12511251
{
12521252
BashExec = [===[
12531253
(while IFS= read -r line; do
1254-
if [ -d "$line" ]; then
1254+
if [ -d "$line" ] && [ ! -L "$line" ]; then
12551255
if rmdir -v -- "${line:?}"; then
12561256
echo LogSuccess: $line deleted >> "${XPLR_PIPE_MSG_IN:?}"
12571257
else
@@ -2038,12 +2038,13 @@ xplr.fn.builtin.fmt_general_table_row_cols_1 = function(m)
20382038
if m.is_broken then
20392039
r = r .. "×"
20402040
else
2041-
r = r .. m.absolute_path
2042-
end
2041+
r = r .. m.symlink.absolute_path
20432042

2044-
if m.symlink.is_dir then
2045-
r = r .. "/"
2043+
if m.symlink.is_dir then
2044+
r = r .. "/"
2045+
end
20462046
end
2047+
20472048
end
20482049

20492050
return r
@@ -2058,7 +2059,7 @@ xplr.fn.builtin.fmt_general_table_row_cols_2 = function(m)
20582059
end
20592060

20602061
xplr.fn.builtin.fmt_general_table_row_cols_3 = function(m)
2061-
if m.is_symlink then
2062+
if m.is_symlink and not m.is_broken then
20622063
return m.symlink.mime_essence
20632064
else
20642065
return m.mime_essence

src/lua.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ mod test {
135135
assert!(check_version(VERSION, "foo path").is_ok());
136136
assert!(check_version("0.10.0", "foo path").is_ok());
137137
assert!(check_version("0.10.1", "foo path").is_ok());
138+
assert!(check_version("0.10.2", "foo path").is_ok());
138139

139-
assert!(check_version("0.10.2", "foo path").is_err());
140+
assert!(check_version("0.10.3", "foo path").is_err());
140141
assert!(check_version("0.9.1", "foo path").is_err());
141142
assert!(check_version("1.10.1", "foo path").is_err());
142143
}

0 commit comments

Comments
 (0)