Bug 503129

Summary: Random subfolders and files missing in "Projects" file listing
Product: [Applications] kate Reporter: Ellie <el>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal CC: christoph, waqar.17a
Priority: NOR    
Version First Reported In: 24.08.3   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Screenshot of file listing for example given in comment https://bugs.kde.org/show_bug.cgi?id=503129#c5
screenshot_waqar
ls_files_output_waqar

Description Ellie 2025-04-21 18:15:31 UTC
SUMMARY

Random subfolders and files seem to be missing in the "Projects" file listing in the side pane, as provided by the projects plugin. The files or folders missing are different for every project I open, and they seem to be random but consistent (always the same missing for the same project, even after reopening kate fully).

The missing entries don't seem to correspond to the .gitignore or any other obvious pattern. In case this is meant to correspond to the .gitignore but somehow buggy, then there should be an option to disable this in Configure > "Projects". In any case, it doesn't seem to be working, no matter how it's intended to operate in practice. Neither restarting kate nor pressing the refresh button seems to resolve this.

STEPS TO REPRODUCE

1.  Enable projects plugin if not yet enabled
2. Open kate without restoring a session. Disable reopening last project if needed, it should show a blank "Untitled" file.
3. Click "File" > "Open Folder..."
4. Open various git clone checkouts of different projects you have on your hard disk.

OBSERVED RESULT

All files and folders in the project folder are listed.

EXPECTED RESULT

Random files and folders appear to be missing. For one project for example, the ".gitignore" just isn't there, but for another one it is. In another one, a "mods" folder is missing for no obvious reason.

SOFTWARE/OS VERSIONS

Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: postmarketOS v24.12
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0

ADDITIONAL INFORMATION
Comment 1 Christoph Cullmann 2025-04-22 18:48:03 UTC
Are the files in the .gitignore list?
Comment 2 Ellie 2025-04-22 18:52:42 UTC
Sometimes they are, sometimes they aren't. For example ".gitignore" itself is missing in one project, and it's not part of the ".gitignore" listing.
Comment 3 Christoph Cullmann 2025-04-22 19:28:46 UTC
(In reply to Ellie from comment #2)
> Sometimes they are, sometimes they aren't. For example ".gitignore" itself
> is missing in one project, and it's not part of the ".gitignore" listing.

If they are in the .gitignore that would be expected behavior.

If not that is a bug, but I can't reproduce this here.
Comment 4 Ellie 2025-04-22 19:43:04 UTC
Is there a toggle to turn that off? For what it's worth, in some other project of mine, files are listed that are clearly also in the .gitignore but this makes more sense to me.
Comment 5 Ellie 2025-04-22 20:06:07 UTC
I tested some more, here seems to be some way to reproduce it on my machine:

    mkdir ~/sometest/
    cd ~/sometest/
    git clone https://codeberg.org/Horse64/core.horse64.org
    cd core.horse64.org
    mkdir ./horse_modules

Then open the folder ~/sometest/core.horse64.org/ in kate. On my machine, there is no ".gitignore" and no ".gitattributes" even though neither are on the git ignore list, and there's a "horse_modules" folder even though that one is on the git ignore list (although I personally think that's good).
Comment 6 Christoph Cullmann 2025-04-22 20:14:54 UTC
I don't think we will show empty folder for git based projects.

We use 

git ls-files to get the files.
Comment 7 Ellie 2025-04-22 20:26:33 UTC
Created attachment 180537 [details]
Screenshot of file listing for example given in comment https://bugs.kde.org/show_bug.cgi?id=503129#c5

The output doesn't seem to match what git ls-files gives me with the example folder specified here: https://bugs.kde.org/show_bug.cgi?id=503129#c5 Not that I want it to, I just want to see listed what's in the folder. ".gitignore" is listed by git ls-files for example, but it's not in the screenshot.
Comment 8 Waqar Ahmed 2025-04-23 03:45:08 UTC
Created attachment 180550 [details]
screenshot_waqar

Screenshot and git ls-files output on my machine with the commands in comment #5.

Git version: git version 2.49.0
Kate version: kate 25.07.70
Comment 9 Waqar Ahmed 2025-04-23 03:45:51 UTC
Created attachment 180551 [details]
ls_files_output_waqar

Output of git ls-files
Comment 10 Waqar Ahmed 2025-04-23 03:53:40 UTC
Maybe you have a global .gitignore (check using: `git config get --global core.excludesFile`) or a different git version. But otherwise this is working as expected.
Comment 11 Ellie 2025-04-23 05:27:49 UTC
git config get --global core.excludesFile outputs nothing, and ".gitignore" still isn't visible. Also, "horse_modules" is visible even though you say it's not meant to be. That doesn't seem to be working as expected.
Comment 12 Waqar Ahmed 2025-04-23 05:34:14 UTC
> That doesn't seem to be working as expected.

Working as expected for me. See my screenshot.
Comment 13 Waqar Ahmed 2025-04-23 05:35:52 UTC
I would suggest that you compare ls files output with my ls files output (attached). If its not same, then its not a Kate bug.

Also, you can disable auto loading of git repos in the settings dialog.
Comment 14 Ellie 2025-04-23 05:47:43 UTC
My apologies for the misunderstanding on my end. As I explained in https://bugs.kde.org/show_bug.cgi?id=503129#c7 the listing doesn't match up for me given the example given in https://bugs.kde.org/show_bug.cgi?id=503129#c5 . When I run git ls-files it 1. lists ".gitignore" (missing in kate, as you can see in my screenshot), and 2. doesn't list "horse_modules" (visible in kate, see my screenshot).

~/sometest/core.horse64.org$ git ls-files | grep horse_modules
tests/compile-fail/import-self-not-allowed/horse_modules/empty.txt
tests/run/args/horse_modules/empty.txt
tests/run/basic-1/horse_modules/empty.txt
tests/run/basic-2/horse_modules/empty.txt
tests/run/cyclic-base/horse_modules/empty.txt
tests/run/extend/horse_modules/empty.txt
tests/run/later-nested-rescue-with/horse_modules/empty.txt
tests/run/later/horse_modules/empty.txt
tests/run/modinit/horse_modules/empty.txt
tests/run/rescue/horse_modules/empty.txt
tests/run/simple-base/horse_modules/empty.txt
translator/translator-h64-runtests/run/args/horse_modules/empty.txt
translator/translator-h64-runtests/run/basic-1/horse_modules/empty.txt
translator/translator-h64-runtests/run/basic-2/horse_modules/empty.txt
translator/translator-h64-runtests/run/cyclic-base/horse_modules/empty.txt
translator/translator-h64-runtests/run/extend/horse_modules/empty.txt
translator/translator-h64-runtests/run/later-nested-rescue-with/horse_modules/empty.txt
translator/translator-h64-runtests/run/later/horse_modules/empty.txt
translator/translator-h64-runtests/run/modinit/horse_modules/empty.txt
translator/translator-h64-runtests/run/rescue/horse_modules/empty.txt
translator/translator-h64-runtests/run/simple-base/horse_modules/empty.txt
~/sometest/core.horse64.org git ls-files | grep gitignore
.gitignore

However, regarding "Also, you can disable auto loading of git repos in the settings dialog" I already did that, and that seems to be part of the problem. It seems to be the case that when auto loading of git repos is disabled, some files are still hidden. Is it perhaps based on them starting with a dot? I'm not sure what exactly is going on here.
Comment 15 Waqar Ahmed 2025-04-23 05:52:15 UTC
... I think you have disabled "Autoload repositories" -> Git". I can reproduce your problem if I disable that setting.

So this bug has nothing to do with Git. 

To fix this:
- Either enable the setting, so you will see what the repo has as per git.
- Add a manual `.kateproject` file, and enable "hidden" files:
```
{
    "name": "my_project_name",
    "files": [
        {
            "git": false,
            "hidden": true
        }
    ],
    "recursive": true
}
```

@Christoph Do you think we should show "hidden" files by default when loading folders?
Comment 16 Ellie 2025-04-23 06:09:25 UTC
> ... I think you have disabled "Autoload repositories" -> Git". I can reproduce your problem if I disable that setting.

That seems to be the case. I think I was trying to make the missing files show up, and then just others disappeared and reappeared, so I didn't realize there was a system to it. My apologies, but I'm glad this part is cleared up. Thanks so much for the input so far.
Comment 17 Christoph Cullmann 2025-04-29 18:53:49 UTC
> @Christoph Do you think we should show "hidden" files by default when
> loading folders?

Not sure about that, you get just a 50:50 chance that this will annoy others that want the current behavior, I would rather keep that as is.
Comment 18 Ellie 2025-04-29 18:57:34 UTC
I suspect it would at least be less surprising to people new to kate, since many dot files are essential, like .gitignore, and them being missing with no explanation is quite baffling. (Also with git integration enabled they aren't missing, making this change even more baffling.) As for people not new to kate, of course somebody's always going to find one way or the other better.
Comment 19 Christoph Cullmann 2025-04-29 19:17:49 UTC
If you have a .gitignore, you have some git and the git auto open is default on, that should then be no issue.
Comment 20 Ellie 2025-04-29 19:28:25 UTC
That isn't practical for me however, since I frequently need to edit the files not tracked by git as well. I don't think that's a rare requirement.