kaihowl / dotfiles

@kaihowl does dotfiles
MIT License
5 stars 0 forks source link

Newly created folder does not show contents in Carbon #758

Closed KaiHoewelmeyer-TomTom closed 4 months ago

kaihowl commented 4 months ago

Repro:

edit .
call input('hit enter')
!mkdir -p hello/ && touch hello/a && touch hello/b
edit hello/
call input('hit enter')
!rm -rf hello/
call input('hit enter')
!mkdir -p hello/ && touch hello/a && touch hello/b
call input('hit enter')

The repro requires a root of a Carbon buffer to be deleted and added again. This leads to a buffer showing any parent of the deleted folder to also not update correctly.

kaihowl commented 4 months ago

Could not reproduce the accidental deletion of the 'hello' folder.

But lua= require('carbon.entry').find('/Users/kaihowl/.dotfiles/hello'):children() returns an empty array while the folder contains files a and b. The entry in the cache seems stale.

Next: Is the watcher correctly treating the item?

kaihowl commented 4 months ago

The watcher is still in place for the folder hello. This is either a problem with libuv and watching a deleted / recreated folder or a problem with carbon's infra.

kaihowl commented 4 months ago

The problem seems to lie with a resync triggered for a view with a non-existent root.

Does this maybe create an entry with a non-directory type? This will later then prevent recursing the children.

kaihowl commented 4 months ago

Found and seemed to have fixed the error: A failure to scan a non-existent folder is treated the same way as encountering an empty folder here. The folder is then treated as empty and stored in the entries.items list. This way it remains empty.

A fix is to add an else case here and treat non userdata cases / nil cases for the handle by returning a nil value instead of an empty table.

kaihowl commented 4 months ago

https://github.com/SidOfc/carbon.nvim/pull/137

kaihowl commented 4 months ago

Fixed with carbon in version 0.20.1. Tested and confirmed.