[Enhancement] Configure showing hidden files#6041
Conversation
nathanlesage
left a comment
There was a problem hiding this comment.
Okay, so, I think I get this PR. In general, I'd argue we should move from hidden files to dot files, just because it's more accurate and won't confuse Windows users, since there "hiding" files involves setting an attribute.
Then, it doesn't seem as if this PR actually ignores .ztr-directory files, or does it?
A few more comments see below.
I had actually originally had this as
No, |
a3cda07 to
4d98e63
Compare
|
I would like to separate the logic of detecting dot-files, and whether they are affected by the show/hide section. We should probably add a simple array to hide specific dot-files and folders; see also issue #6061. I believe there could be three "layers" of dot files:
Settings-wise it might make sense to capture it like so:
Optionally (but I'd argue we should not implement before we actually need it), we could also add a token list-input (like for the attachment extensions) where users could provide additional dot files that should be hidden in addition. |
|
I think user defined files are out of scope for this, and I dont really have interest in implementing that here. Regarding always hidden files (.git, etc), should those always be hidden--i.e, no setting to make them visible, or should there be a separate setting to make them visible? I can get behind always hidden, but a separate setting in my opinion would only confuse users who have to track down two settings for essentially the same functionality. |
|
Also, in what layer should the always hidden files be filtered? Currently, git folders are filtered in the FSAL layer because we dont want to recurse into them, which causes issues when parsing certain "exotic" files within the folder. However, every other file/folder is filtered at the ui level |
|
I'm fine with no option for that. Again, Zettlr only provides a view over the file system, and Is argue users can also always use the computer file browser to view those hidden folders. I'd also say all hidden files should be filtered at the FSAL level, that is, not even be parsed. This reduces the memory footprint and avoids potential footguns where hidden folders contain a bazillion plain text files that are of no concern to Zettlr. The less we parse, the better. That was also why I was initially hesitant of such a prominent setting... |
|
Thats definitely doable! Do you have a list in mind of files/folders to always ignore? It can start off simple, too |
4d98e63 to
10933f2
Compare
|
As the author of #6061, I agree that hiding hidden or dot files could be expanded to completely ignore them. Regarding hardcoding the list of files, could it be just a setting for files or regular expressions that Zettlr ships with? These could then be overriden by the user either through the settings interface or by editing a text configuration file (if the settings inteface complexity shouldnt be increased and there is no need for new panel) . I don’t expect this to be a common occurrence but sometimes someone might want at least some of these files accessible in very rare cases. |
|
So again, I'm not going to implement user-configured hidden files in this PR. I think there's more discussion to be had on the UI and UX of that feature. Regarding what kind of files are included in the hardcoded list, I would really only want these to be files and folders users have no business editing regardless -- i.e, people should not be messing around in the |
|
I concur with @benniekiss here. Also, there will be many more releases! As to a potential starting list of what should always be ignored, we might want to start with common gitignore lists and see what we find that might commonly end up in user directories! I don't think that list will be very long, though. One additional thing would be |
|
if I can add to the list a quite often folders to exclude can be |
|
Last commit is a WIP to implementing the hard-coded list and filtering at the FSAL level. I believe its 90% there, I just haven't tested extensively. I renamed the Even though we filter at the FSAL level, we still need filtering at the UI level. Since the show dot files config option has two parts -- the file manager and the sidebar -- there may be instances where dotfiles are in the tree but shouldn't be shown in a particular context. One question I had was how to address watchdog handling. Currently, I re-use the |
|
Everything that is filtered out at the FSAL level also needs to be ignored in the watchdog, especially since changes to git folders would emit a huge amount of events that can have a performance impact on Zettlr because the main loop is busy sending out events into the void. I just had another question: do we generally need to distinguish between dot files and dot folders? |
Currently, Zettlr/source/app/service-providers/fsal/fsal-watchdog.ts Lines 112 to 124 in 0904e1c
I don't think so, and there's no distinction in the code currently. |
Given that Zettlr may need to react to those changes, we should leave it. But anything that Zettlr doesn't need should be ignored. If we have to extend the list of exceptions in the future so be it! |
So I did some testing to see what was emitted for git dirs, and I don't think anything relies on those types of event, and I don't think the code actually picks them up anyways. In a separate terminal, I tried doing some git commands on a folder opened as a workspace in Zettlr, and no events were emitted, doing things like Regarding |
7c696be to
8ece6e1
Compare
|
Great – yes, changes to the |
35fc450 to
1f5ba2f
Compare
|
Last commit builds the regex programmatically, which I think addresses all your points. I believe this is good to go on my end |
|
Great, thank you so much! I will be merging this after 4.0 stable comes out, simply because I don't want to risk any potential delays. I'll release Zettlr 4.0 on Dec 26, so this thing will be merged this year. FYI: I have taken the liberty of cherrypicking the fix for #5949 from this PR just to get that one bugfix over the bridge, too 👀 |
1f5ba2f to
47cb4b1
Compare
f3f8b31 to
0006a81
Compare
* since files are filtered at the FSAL level, when * the config is changed, we need to update the list * of files
Co-authored-by: nipahutgardens <84083988+nipahutgardens@users.noreply.github.com>
f7a2ed5 to
ee42026
Compare
nathanlesage
left a comment
There was a problem hiding this comment.
I want to finally commit this large PR, and now that the code signing works again I believe we can take some risk with this large PR. A few, exclusively style-related suggestions. The code itself looks good.
(Also, nota bene: I just realized that, especially when it comes to big PRs, it is much easier for me to understand the code flow only when I haven't looked at the Zettlr source code for two weeks, and I have no idea why that is. But this time around I suddenly understood the entire PR!)
| try { | ||
| dir.isGitRepository = (await fs.lstat(path.join(dir.path, '.git'))).isDirectory() | ||
| } catch (err: any) {} | ||
|
|
There was a problem hiding this comment.
Can't we do a simple isDir-check? That would avoid this try/catch contraption.
There was a problem hiding this comment.
isDir is sync, which is why I avoided it here, but otherwise I have no problem using it.
|
|
||
| return [ directoryPath, ...(await Promise.all(contents)).flat() ] | ||
| const { files } = this._config.get() | ||
| const ignoreDotFiles = !(files.dotFiles.showInFilemanager || files.dotFiles.showInSidebar) |
There was a problem hiding this comment.
Isn't this suggestion equal? Would avoid easy to miss brackets.
| const ignoreDotFiles = !(files.dotFiles.showInFilemanager || files.dotFiles.showInSidebar) | |
| const ignoreDotFiles = !files.dotFiles.showInFilemanager && !files.dotFiles.showInSidebar |
There was a problem hiding this comment.
The current version short circuits, but otherwise they are the same end result
There was a problem hiding this comment.
Totally glossed over that your suggestion also short circuits, so Im gonna merge the change!
|
|
||
| const children = await fs.readdir(absPath) | ||
| const { files } = this._config.get() | ||
| const ignoreDotFiles = !(files.dotFiles.showInFilemanager || files.dotFiles.showInSidebar) |
|
Also, I appreciate that you took the time to fix a bunch of newly introduced |
Co-authored-by: Hendrik Erz <hendrik@zettlr.com>
Co-authored-by: Hendrik Erz <hendrik@zettlr.com>
Co-authored-by: Hendrik Erz <hendrik@zettlr.com>
Co-authored-by: Hendrik Erz <hendrik@zettlr.com>
Co-authored-by: Hendrik Erz <hendrik@zettlr.com>
Co-authored-by: Hendrik Erz <hendrik@zettlr.com>
Co-authored-by: Hendrik Erz <hendrik@zettlr.com>
|
Just want your final opinions on the |
|
Thanks a bunch! Looks good now – merging |
Description
This PR allows a user to configure whether hidden files are shown in the sidebar and file manager.
Closes #6040
Closes #5949
Changes
A configuration option was added to the advanced settings pane allowing a user to configure whether hidden files and directories (essentially dot files) are shown in the file manager and sidebar.
Additional extensions configured in the advanced settings pane now show up in the file manager.
Hidden file detection was refactored to be consolidated within the file sorting methods of the
TreeItem,FileList, andworkspace-store. Now, the FSAL indexing includes all files.A check was added to the
readDirectoryRecursivelyandreadDirectoryFSAL methods to check if the directory is a.gitdir, in which case parsing is skipped.ignoreDirhandling was consolidated, and the FSAL watchdog was updated to use theignoreDirfunction. The regex to ignore dot files was commented out so that changes to dot files are picked up when a user has them visible.The
getFilesystemMetadatafunction was refactored to be more streamlined and remove references to recursive parsing, which is now no longer handled by this function. The call tofs.statwas changed tofs.lstatto detect symlinks and prevent crashes when they are in the tree. This led to the target beingstat'd, but then the subsequent call toreadFilewould fail because it tries to read the link path, not the target path.Additional information
Tested on: