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

show tree edge before name block #489

Merged
merged 9 commits into from
Mar 27, 2021
Merged

Conversation

zwpaper
Copy link
Member

@zwpaper zwpaper commented Feb 15, 2021

show tree edge before name block

fix #468

TODO

  • Use cargo fmt
  • Add necessary tests
  • Add changelog entry

@codecov-io
Copy link

codecov-io commented Feb 15, 2021

Codecov Report

Merging #489 (f26f193) into master (7d04dcb) will increase coverage by 4.02%.
The diff coverage is 93.79%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #489      +/-   ##
==========================================
+ Coverage   84.46%   88.48%   +4.02%     
==========================================
  Files          36       36              
  Lines        3456     3535      +79     
==========================================
+ Hits         2919     3128     +209     
+ Misses        537      407     -130     
Impacted Files Coverage Δ
src/color.rs 78.64% <ø> (ø)
src/meta/filetype.rs 81.05% <66.66%> (-0.67%) ⬇️
src/display.rs 72.93% <93.38%> (+48.31%) ⬆️
src/meta/date.rs 98.27% <100.00%> (+0.83%) ⬆️
src/meta/size.rs 94.73% <100.00%> (+0.58%) ⬆️
tests/integration.rs 100.00% <100.00%> (ø)
src/flags/date.rs 95.27% <0.00%> (+0.67%) ⬆️
src/meta/symlink.rs 69.38% <0.00%> (+2.04%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d04dcb...f26f193. Read the comment docs.

@meain
Copy link
Member

meain commented Feb 17, 2021

@zwpaper , thanks for taking this up.

One thing that I am concerned with is handling --tree along with --blocks. I am not sure how we should handle if someone does something like lsd --tree --blocks permissions,name,date.

Btw with this PR, if I am using date relative and the entire folder has a "smaller" date. The tree is misaligned.

.rw-r--r-- 2.4K a month ago   │  ├── indicators.rs
.rw-r--r-- 4.0K a month ago   │  ├── layout.rs
.rw-r--r-- 8.8K 2 minutes ago │  ├── recursion.rs
.rw-r--r-- 4.0K 2 minutes ago │  ├── size.rs
.rw-r--r--  16K 2 minutes ago │  ├── sorting.rs
.rw-r--r-- 2.1K a month ago   │  ├── symlink_arrow.rs
.rw-r--r-- 2.4K a month ago   │  ├── symlinks.rs
.rw-r--r-- 2.4K a month ago   │  └── total_size.rs
.rw-r--r-- 4.5K 2 days ago    ├── flags.rs
.rw-r--r--  18K 2 days ago    ├── icon.rs
.rw-r--r-- 2.7K 2 days ago    ├── main.rs
drwxr-xr-x 448B 2 days ago    ├── meta
.rw-r--r-- 8.1K 2 days ago   │  ├── date.rs
.rw-r--r-- 8.6K a month ago  │  ├── filetype.rs
.rw-r--r-- 2.6K a month ago  │  ├── indicator.rs
.rw-r--r-- 1.5K 2 months ago │  ├── inode.rs
.rw-r--r-- 1.5K 2 days ago   │  ├── links.rs
.rw-r--r-- 7.1K 2 days ago   │  ├── mod.rs
.rw-r--r--  16K 2 days ago   │  ├── name.rs
.rw-r--r-- 1.2K 2 days ago   │  ├── owner.rs
.rw-r--r-- 4.6K a month ago  │  ├── permissions.rs
.rw-r--r--  10K a month ago  │  ├── size.rs
.rw-r--r-- 3.3K a month ago  │  ├── symlink.rs
.rw-r--r--  11K 2 days ago   │  └── windows_utils.rs
.rw-r--r--  10K 2 weeks ago   └── sort.rs

@zwpaper
Copy link
Member Author

zwpaper commented Feb 17, 2021

hi @meain , previously I have thought about making the tree edge as a block, but it would be weirder if users have to specify the tree edge option when using --blocks.

so I decided to make it stick with the name block, IMHO the tree edge seems to be useful when it stays with the name block.
if users specified lsd --tree --blocks permissions,name,date, they should be expecting the date block is not align in its column, or we can document it.

as the "smaller" date misaligned part, let me will dig deeper into it

@meain
Copy link
Member

meain commented Feb 18, 2021

I initially did think of having tree as a block as well. We can default it to the start of the block list if --tree is set but no tree block is given by the user. But to be frank that kinda felt like a bit too much.

Another issue with assigning --tree to just name is that if someone does lsd --tree --blocks permission,date it does not show a tree at all.

Here is one other idea, I am not fully convinced of this myself but thought I would throw it out there. We can have another flag --tree-position which can accept start, name. Also if the user gives --tree-position as name but does not have name in the blocks, we can change it to start automatically.

@zwpaper
Copy link
Member Author

zwpaper commented Feb 18, 2021

I just feel like that both the block and --tree-position seems a little bit too heavy.

standing on the user case, is there really a case that users did not show the name block?

@meain
Copy link
Member

meain commented Feb 18, 2021

I don't think there is a strong usecase for blocks withoutname, but --tree should probably draw a tree even if name is not specified in the blocks. How about we revert to drawing the tree symbols in the start if no name is specified else with tree next to name? This wold work when user does an simple -l listing. One issue that I can think for this is that it might change the workflow of someone who might be using name neither at the start or at the end(not that bad though actually).

Screenshot 2021-02-18 at 12 24 11 PM

@zwpaper
Copy link
Member Author

zwpaper commented Feb 18, 2021

there is a bug in the original tree column calculation, I am working on it and then the last case you mentioned, nerther start nor end , columns will stay aligned.

following your idea, if there is no name block, we add the tree prefix to the first column, making it align like a tree, while others align in column, ok?

@zwpaper
Copy link
Member Author

zwpaper commented Feb 18, 2021

I have fixed the align problems including

  1. check alignment for both dir and all sub dirs
  2. check size padding for bot dir and all sub dirs

now there should not be align problems.

I will work onto show the tree edge when there is no name block

@zwpaper zwpaper force-pushed the dev-tree-long branch 3 times, most recently from 2255b28 to 729feaa Compare February 19, 2021 15:09
@zwpaper
Copy link
Member Author

zwpaper commented Feb 19, 2021

hi @meain , this PR should be ready now.

with name:

λ lsd --tree --date relative --blocks permission,size,date,name
drwxr-xr-x 416 B  3 minutes ago  .
.rw-r--r--  11 KB 5 days ago    ├──  app.rs
.rw-r--r-- 7.3 KB a day ago     ├──  color.rs
.rw-r--r--  10 KB 3 days ago    ├──  config_file.rs
.rw-r--r-- 4.7 KB 3 weeks ago   ├──  core.rs
.rw-r--r--  20 KB 3 minutes ago ├──  display.rs
drwxr-xr-x 544 B  3 days ago    ├──  flags
.rw-r--r--  16 KB 3 days ago    │  ├──  blocks.rs
.rw-r--r-- 5.9 KB 3 weeks ago   │  ├──  color.rs
.rw-r--r-- 9.1 KB 3 weeks ago   │  ├──  date.rs
.rw-r--r-- 2.4 KB 3 weeks ago   │  ├──  dereference.rs
.rw-r--r-- 3.9 KB 3 weeks ago   │  ├──  display.rs
.rw-r--r--  11 KB 3 weeks ago   │  ├──  icons.rs
.rw-r--r-- 6.6 KB 3 weeks ago   │  ├──  ignore_globs.rs
.rw-r--r-- 2.4 KB 3 weeks ago   │  ├──  indicators.rs
.rw-r--r-- 4.0 KB 3 weeks ago   │  ├──  layout.rs
.rw-r--r-- 8.8 KB 3 weeks ago   │  ├──  recursion.rs
.rw-r--r-- 4.0 KB 3 weeks ago   │  ├──  size.rs
.rw-r--r--  16 KB 3 days ago    │  ├──  sorting.rs
.rw-r--r-- 2.1 KB 3 weeks ago   │  ├──  symlink_arrow.rs
.rw-r--r-- 2.4 KB 3 weeks ago   │  ├──  symlinks.rs
.rw-r--r-- 2.4 KB 3 weeks ago   │  └──  total_size.rs
.rw-r--r-- 4.5 KB 3 weeks ago   ├──  flags.rs
.rw-r--r--  18 KB 3 weeks ago   ├──  icon.rs
.rw-r--r-- 2.7 KB 3 weeks ago   ├──  main.rs

without name:

λ lsd --tree --date relative --blocks size,permission,date
416 B         drwxr-xr-x 4 minutes ago
├── 11 KB     .rw-r--r-- 5 days ago
├── 7.3 KB    .rw-r--r-- a day ago
├── 10 KB     .rw-r--r-- 3 days ago
├── 4.7 KB    .rw-r--r-- 3 weeks ago
├── 20 KB     .rw-r--r-- 4 minutes ago
├── 544 B     drwxr-xr-x 3 days ago
│  ├── 16 KB  .rw-r--r-- 3 days ago
│  ├── 5.9 KB .rw-r--r-- 3 weeks ago
│  ├── 9.1 KB .rw-r--r-- 3 weeks ago
│  ├── 2.4 KB .rw-r--r-- 3 weeks ago
│  ├── 3.9 KB .rw-r--r-- 3 weeks ago
│  ├── 11 KB  .rw-r--r-- 3 weeks ago
│  ├── 6.6 KB .rw-r--r-- 3 weeks ago
│  ├── 2.4 KB .rw-r--r-- 3 weeks ago
│  ├── 4.0 KB .rw-r--r-- 3 weeks ago
│  ├── 8.8 KB .rw-r--r-- 3 weeks ago
│  ├── 4.0 KB .rw-r--r-- 3 weeks ago
│  ├── 16 KB  .rw-r--r-- 3 days ago
│  ├── 2.1 KB .rw-r--r-- 3 weeks ago
│  ├── 2.4 KB .rw-r--r-- 3 weeks ago
│  └── 2.4 KB .rw-r--r-- 3 weeks ago
├── 4.5 KB    .rw-r--r-- 3 weeks ago
├── 18 KB     .rw-r--r-- 3 weeks ago
├── 2.7 KB    .rw-r--r-- 3 weeks ago

src/color.rs Outdated Show resolved Hide resolved
src/display.rs Show resolved Hide resolved
src/display.rs Outdated Show resolved Hide resolved
src/display.rs Outdated Show resolved Hide resolved
prefix: &str,
) -> String {
let mut output = String::new();
tree_depth_prefix: (usize, &str),
Copy link
Member

Choose a reason for hiding this comment

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

IMO, I think it would be cleaner to keep depth and prefix as two separate values itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I change this only because of the too_many_arguments warning, sigh...

and I can not figure out a better way to reduce the number of args, is there a better solution in your sight?

warning: this function has too many arguments (8/7), #[warn(too_many_arguments)] on by default

@meain
Copy link
Member

meain commented Mar 12, 2021

@zwpaper The --tree test that is failing in all of these is actually something that caused me issues when releasing 0.20.0. Not exactly sure what is going on, but that test behaves different in macos vs linux. Also for some reason only randomly on this repo's CI alone. It does not fail in the CI run in my fork. I have removed this temporarily in master for now. Need to figure out what is going on with this one. I even try adding --timesort and it was still causing this issue.

zwpaper added 6 commits March 14, 2021 00:12
Signed-off-by: zwPapEr <zw.paper@gmail.com>
Signed-off-by: zwPapEr <zw.paper@gmail.com>
Signed-off-by: zwPapEr <zw.paper@gmail.com>
Signed-off-by: zwPapEr <zw.paper@gmail.com>
Signed-off-by: zwPapEr <zw.paper@gmail.com>
Signed-off-by: zwPapEr <zw.paper@gmail.com>
@zwpaper
Copy link
Member Author

zwpaper commented Mar 13, 2021

@meain I have found the problem for the test, sorting is done before display, so that timesort is ignored.

I have updated the code, and sorry for the force push, Have to rebase on to master

@zwpaper zwpaper requested a review from meain March 14, 2021 13:14
@meain
Copy link
Member

meain commented Mar 14, 2021

Thanks for looking into the tree test. I am a bit busy now, will try to get the reviewed before next week.

About force push, all good. In fact that is what you should be doing to fix issues in PRs. Just don't force push squashing every commit while working on the changes as that will make it harder to review in case someone has already taken a look at the previous commit.

@SuperSandro2000
Copy link
Contributor

If the branch is not rebased on master you can also view the diff between the force pushes https://github.com/Peltoche/lsd/compare/5a558275fd37fe8efe0fa0e78bfc97da1b89c3dd..6a8ae5bdaabf1b941438e9962cc45fa60b56d58a

CHANGELOG.md Outdated Show resolved Hide resolved
@@ -254,6 +256,8 @@ impl Colors {
m.insert(Elem::Links { valid: true }, Colour::Fixed(13));
m.insert(Elem::Links { valid: false }, Colour::Fixed(245));

// TODO add this after we can use file to configure theme
// m.insert(Elem::TreeEdge, Colour::Fixed(44)); // DarkTurquoise
Copy link
Member

Choose a reason for hiding this comment

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

Wanted to do this a little while ago, I think we can make the color that is returned an Option and make this return None? I think we can take that up in another PR as well. This would let us remove the #[allow(dead_code)] above the struct definition.

Copy link
Member Author

Choose a reason for hiding this comment

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

#506 issue created

src/display.rs Outdated Show resolved Hide resolved
zwpaper added 2 commits March 25, 2021 15:50
Signed-off-by: zwPapEr <zw.paper@gmail.com>
Signed-off-by: zwPapEr <zw.paper@gmail.com>
@zwpaper zwpaper requested a review from meain March 25, 2021 08:19
@meain
Copy link
Member

meain commented Mar 27, 2021

LGTM

@meain meain merged commit 7254816 into lsd-rs:master Mar 27, 2021
@meain meain mentioned this pull request Mar 28, 2021
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.

Change the display of --tree when used alongside --long
5 participants