dense-analysis / dense-analysis/ale

ALEPreviewWindow file relocation due to unnecessary fs events

Open Beginner friendly
#5,158 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

I'm experiencing extraneous client reloads due to a file named `ALEPreviewWindow` getting created and deleted immediately in the source tree, triggering the development watcher. It is unexpected and... felt kinda intrusive :)

It seems that the culprint is this line:

https://github.com/dense-analysis/ale/blob/master/autoload/ale/preview.vim#L28

It uses `pedit` to open a preview window, passing `ALEPreviewWindow` argument to it, I guess because _some_ argument is expected to name the window. The file itself is getting created by Vim probably, cause there's no trace of actually saving it in the ALE code. Not sure if this is intended in Vim either.

I logged the events from `@parcel/watcher` to make sure this actually happens:

```
events [
{
path: "C:\\...\\src\\client\\ALEPreviewWindow",
type: "create",
}
]
events [
{
path: "C:\\...\\src\\client\\ALEPreviewWindow",
type: "delete",
}
]
```

My monkey-patch workaround is to simply replace the filename with something that touches file system outside of the source tree:

```diff
diff --git a/autoload/ale/preview.vim b/autoload/ale/preview.vim
index 1aca03ea..0b707bef 100644
--- a/autoload/ale/preview.vim
+++ b/autoload/ale/preview.vim
@@ -25,7 +25,7 @@ endfunction
function! ale#preview#Show(lines, ...) abort
let l:options = get(a:000, 0, {})

- silent pedit ALEPreviewWindow
+ silent pedit ~/ALEPreviewWindow
wincmd P

setlocal modifiable
```

I suggest to add this in some release cause it seems to work without any issues (at least for my use cases).

I should add that I have "cwd follow the buffer's dirname" setting on in my Vim, so when I switch to a buffer, it automatically `cd`'s the Vim process into it. So you won't experience this under default settings, since cwd is then usually a project root or some dir that rarely gets watched.

Contributor guide

Open the contributing guide

Research direction

Start in autoload/ale/preview.vim at ale#preview#Show and inspect the pedit call around line 28. Reproduce with Vim's cwd-follow-buffer setting and a filesystem watcher, then verify the preview window no longer creates and deletes ALEPreviewWindow inside the watched source tree.

Written by the indexing model from the issue text.

Assessment

Tech stack
vim
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.