facultyai / faculty-sync

Synchronise a local directory with your Faculty platform workspace
https://pypi.org/project/faculty_sync/
Apache License 2.0
10 stars 1 forks source link

Long paths are truncated in watch mode #30

Open tcbegley opened 5 years ago

tcbegley commented 5 years ago

When using watch mode on a large project with many nested directories, I see only the first part of the path before it gets truncated. In particular the actual file name is hidden. Resizing the window has no effect.

image

Would it be possible to display something like notebooks/.../folder/notebook_name.ipynb etc.?

janfreyberg commented 5 years ago

good catch @tcbegley , thanks

pbugnion commented 5 years ago

What would be the most useful here? Something like notebooks/.../<last-directory>/<filename>?

tcbegley commented 5 years ago

For me that would be perfect

janfreyberg commented 5 years ago

I reckon what makes sense is to recursively remove directories before the last directory until it gets to an acceptable path length

srstevenson commented 5 years ago

An alternative which provides more context than eliding intermediate directory names is to keep only the first character of each parent directory's name. For example, /project/some/very/long/nested/path/foo.ipynb would be displayed as /p/n/s/v/l/n/p/foo.ipynb. This is especially useful if the project contains multiple directories with generic names used in multiple places. For example:

$ tree /project 
/project
├── exploration
│   ├── doc
│   ├── notebooks
│   └── src
├── modelling
│   ├── doc
│   ├── notebooks
│   └── src
└── visualisation
    ├── doc
    ├── notebooks
    └── src
janfreyberg commented 5 years ago

I think just sticking a single letter in there is a bit confusing. I've just written something that replaces the longest directory with the first letter + … recursively, and if that doesn't get it below the char limit, it starts removing directories entirely (replacing with a single …)

Does this seem reasonable?

_trim_path('/hi/this/is/a/really_really/reeeeeeeeeeeeeeeeeally/loooooooooooooooooooooong/path.file')
'hi/this/is/a/really_really/r…/l…/path.file'
srstevenson commented 5 years ago

To me that's more confusing than always reducing to a single character. Additionally, it's less apparent why a particular directory name has been elided than if it was just applied left-to-right, for example.

pbugnion commented 5 years ago

Thanks for everyone's contributions and enthusiasm.

Scott's suggestion is fairly common (the Fish prompt does this by default, I think, or maybe it's just my prompt), and should therefore be fairly familiar. That said, I think Jan's idea of having a first letter + ... is somewhat more legible, at the cost of an extra character. Ultimately I don't really care -- I think we should just try it.

In terms of where to truncate, I believe it'd be more aligned with people's expectations (and probably more useful) to start truncating directories at the beginning of the path rather than at the end, or rather than choosing the longest directories:

/hi/this/is/a/really_really/reeeeeeeeeeeeeeeeeally/loooooooooooooooooooooong/path.file
=>
/h/t/i/a/r/r/loooooooooooooooooooooong/path.file
/h…/t…/i…/a…/r…/loooooooooooooooooooooong/path.file

Can we just test that the ellipsis character prints reasonably on the Cygwin terminal in the Windows computer?

janfreyberg commented 5 years ago

will do @pbugnion!

janfreyberg commented 5 years ago

Can confirm that this does indeed print in cygwin.