stevearc / oil.nvim

Neovim file explorer: edit your filesystem like a buffer
MIT License
3.84k stars 110 forks source link

perf(trash_windows): use a single powershell instance for operations #271

Closed TheLeoP closed 8 months ago

TheLeoP commented 9 months ago

As mentioned in #243, trash support on windows is slow for some operations because it spawns a powershell process for every operation (sending 10 files to trash would spawn 10 powershell instances).

This PR starts two powershell intances (one for listing and one for deleting) and communicates with them over stdio (sending 10 files to trash now spawns only 1 powershell instance).

This improves the performance of trash related operations in windows after the first operation (because it's neccesary to start the powershell instance the first time). Maybe it could be preffered to start the powershell instances on startup instead (?).

TheLeoP commented 9 months ago

Is this approach ok? I'm not sure about how the initial command are handled (I tried to use coroutines, but got an error because they can't be used across c call boundaries). Also, the API isn't trash specific, would an trash specific API be preffered?

TheLeoP commented 8 months ago

I didn't undestand how _consume was suppossed to work inside the on_stdout callback and your comment made it click for me. This allowed me to simplify the initialization code a lot. Is it better? Or would it still be preffered to extract it into a different file?

stevearc commented 8 months ago

I shuffled around some of the logic. LMK if this makes sense (and if it still works for you)

TheLeoP commented 8 months ago

Looks good to me and it's working as expected c: