summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyohei Uto <kyoheiu@outlook.com>2022-10-21 05:29:21 +0900
committerGitHub <noreply@github.com>2022-10-21 05:29:21 +0900
commitf8b7ef52fe4a61589eb83d17594e6b939282e691 (patch)
tree93222cccb314af41214fa661026b2b27c84e2104
parenteeb98e31cd4489cf8683761ab23e0a22f9807e2a (diff)
parentfc671d044b84c78cf41e018440045f5d0bccf38c (diff)
Merge pull request #122 from kyoheiu/developv1.3.1
v1.3.1
-rw-r--r--.github/workflows/install_test.yml2
-rw-r--r--.github/workflows/pr_test.yml50
-rw-r--r--CHANGELOG.md6
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--README.md6
-rw-r--r--config.toml2
-rw-r--r--src/functions.rs2
-rw-r--r--src/help.rs7
-rw-r--r--src/layout.rs19
10 files changed, 38 insertions, 60 deletions
diff --git a/.github/workflows/install_test.yml b/.github/workflows/install_test.yml
index 8cd98ce..2aba090 100644
--- a/.github/workflows/install_test.yml
+++ b/.github/workflows/install_test.yml
@@ -5,6 +5,8 @@ on:
branches-ignore: 'main'
paths-ignore:
- '*.md'
+ pull_request:
+ types: [opened, edited, reopened]
env:
CARGO_TERM_COLOR: always
diff --git a/.github/workflows/pr_test.yml b/.github/workflows/pr_test.yml
deleted file mode 100644
index 2017eb9..0000000
--- a/.github/workflows/pr_test.yml
+++ /dev/null
@@ -1,50 +0,0 @@
-name: "pull request install test"
-
-on:
- pull_request:
- types: [opened, edited, reopened]
-
-env:
- CARGO_TERM_COLOR: always
-
-jobs:
- ubuntu-install:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Install
- run: |
- cargo install --path .
- macos-install:
- runs-on: macos-latest
- steps:
- - uses: actions/checkout@v2
- - name: Install
- run: |
- cargo install --path .
- archlinux-install:
- runs-on: ubuntu-latest
- container:
- image: archlinux:base-devel
- steps:
- - uses: actions/checkout@v2
- - name: Install
- run: |
- pacman -Syu --noconfirm
- pacman -S rustup --noconfirm
- rustup install stable
- rustup default stable
- cargo install --path .
- windows-install:
- runs-on: windows-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v1
- - name: Install latest rust toolchain
- uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- default: true
- override: true
- - name: Install
- run: cargo install --path .
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2ddeac2..0ebbd8b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,12 @@
## Unreleased
+## v1.3.1 (2022-10-21)
+
+### Fixed
+
+- Attempting to preview a symbolic link to a directory caused a panic. It has been fixed and the preview will now show the contents of the linked directory.
+
## v1.3.0 (2022-10-18)
### Changed
diff --git a/Cargo.lock b/Cargo.lock
index f52f4a1..2859d7f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -109,7 +109,7 @@ dependencies = [
[[package]]
name = "felix"
-version = "1.3.0"
+version = "1.3.1"
dependencies = [
"chrono",
"content_inspector",
diff --git a/Cargo.toml b/Cargo.toml
index b9ba4fd..5fd0cb1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "felix"
-version = "1.3.0"
+version = "1.3.1"
authors = ["Kyohei Uto <kyoheiu@outlook.com>"]
edition = "2021"
description = "tui file manager with vim-like key mapping"
diff --git a/README.md b/README.md
index 5a02b46..66871cf 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,12 @@ For the detailed document, please see https://kyoheiu.dev/felix.
## New Release
+## v1.3.1 (2022-10-21)
+
+### Fixed
+
+- Attempting to preview a symbolic link to a directory caused a panic. It has been fixed and the preview will now show the contents of the linked directory.
+
## v1.3.0 (2022-10-18)
### Changed
diff --git a/config.toml b/config.toml
index 99c8029..bf5ee7a 100644
--- a/config.toml
+++ b/config.toml
@@ -1,4 +1,4 @@
-# 1.3.0
+# 1.3.1
# (Optional) Default exec command when open files.
# If not set, will default to $EDITOR
diff --git a/src/functions.rs b/src/functions.rs
index 04a926f..c5636eb 100644
--- a/src/functions.rs
+++ b/src/functions.rs
@@ -169,7 +169,7 @@ pub fn to_proper_size(byte: u64) -> String {
}
/// Generate the contents of item to show as a preview.
-pub fn list_up_contents(path: PathBuf) -> Result<Vec<String>, FxError> {
+pub fn list_up_contents(path: &Path) -> Result<Vec<String>, FxError> {
let mut file_v = Vec::new();
let mut dir_v = Vec::new();
let mut result = Vec::new();
diff --git a/src/help.rs b/src/help.rs
index dd54c6b..bea4ff9 100644
--- a/src/help.rs
+++ b/src/help.rs
@@ -1,5 +1,5 @@
/// Help text.
-pub const HELP: &str = "# felix v1.3.0
+pub const HELP: &str = "# felix v1.3.1
A simple TUI file manager with vim-like keymapping.
## Usage
@@ -60,5 +60,10 @@ config file : $HOME/Library/Application Support/felix/config.toml
trash directory: $HOME/Library/Application Support/felix/trash
log files : $HOME/Library/Application Support/felix/log
+### Windows
+config file : $PROFILE\\AppData\\Roaming\\felix\\config.toml
+trash directory : $PROFILE\\AppData\\Roaming\\felix\\trash
+log files : $PROFILE\\AppData\\Roaming\\felix\\log
+
For more details, visit https://github.com/kyoheiu/felix
";
diff --git a/src/layout.rs b/src/layout.rs
index 4db107c..88c0f8d 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -96,9 +96,13 @@ impl Layout {
/// Print text preview on the right half of the terminal.
fn preview_content(&self, item: &ItemInfo, is_dir: bool) {
let content = if is_dir {
- if let Ok(content) = list_up_contents(item.file_path.clone()) {
- if let Ok(content) = make_tree(content) {
- format_txt(&content, self.preview_width, false)
+ let contents = match &item.symlink_dir_path {
+ None => list_up_contents(&item.file_path),
+ Some(p) => list_up_contents(p),
+ };
+ if let Ok(contents) = contents {
+ if let Ok(contents) = make_tree(contents) {
+ format_txt(&contents, self.preview_width, false)
} else {
vec![]
}
@@ -219,12 +223,17 @@ pub fn make_layout(
fn check_preview_type(item: &ItemInfo) -> PreviewType {
if item.file_size > MAX_SIZE_TO_PREVIEW {
PreviewType::TooBigSize
- } else if item.file_type == FileType::Directory {
+ } else if item.file_type == FileType::Directory
+ || (item.file_type == FileType::Symlink && item.symlink_dir_path.is_some())
+ {
PreviewType::Directory
} else if is_supported_ext(item) {
PreviewType::Image
} else {
- let content_type = content_inspector::inspect(&std::fs::read(&item.file_path).unwrap());
+ let content_type = content_inspector::inspect(
+ &std::fs::read(&item.file_path)
+ .unwrap_or_else(|_| panic!("failed check preview type.")),
+ );
if content_type.is_text() {
PreviewType::Text
} else {