Location list cannot be used/tested after caught error
- Dominant language
- Vim Script
- Stars
- 599
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
When any Vim error occurs during a Vader test (despite being caught by a `try/catch` block), any further attempts to read from the location list will fail.
Example (`test.vader`):
```vim
Execute (Test location list):
lvimgrep /i_will_match/ test.vader
Log getloclist(0)
Assert !empty(getloclist(0))
Execute (Test location list after "error"):
try | lvimgrep /^no-match/ test.vader | catch | endtry
lvimgrep /i_should_match/ test.vader
Log getloclist(0)
Assert !empty(getloclist(0))
```
The first test will succeed (the location list returned by `getloclist(0)` contains the results of the `lvimgrep` command.
The second test intentionally fails to match and `lvimgrep` throws an error, which we catch.
That's fine.
But thereafter, any subsequent attempts to perform an `lvimgrep` and inspect the location list will fail (`getloclist(0)` returns an empty list).
The Vader results:
```
Starting Vader: 1 suite(s), 2 case(s)
Starting Vader: /home/dave/.vim/bundle/vimwiki/test/test.vader
(1/2) [EXECUTE] Test location list
> [{'lnum': 2, 'bufnr': 1, 'col': 13, 'valid': 1, 'vcol': 0, 'nr': 0, 'type': '', 'pattern': '', 'text': ' lvimgrep /i_will_match/ test.vader'}]
(2/2) [EXECUTE] Test location list after "error"
> []
(2/2) [EXECUTE] (X) Assertion failure
Success/Total: 1/2
Success/Total: 1/2 (assertions: 1/2)
Elapsed time: 0.034826 sec.
```
What _does_ work:
* Running `lvimgrep` manually and inspecting the location list with `:echo getloclist(0)`
* Doing the above manually after a failed search or any other error
* Running any number of `lvimgrep` searches in Vader tests...until an error is thrown
Any fix, work-around, or alternative way of testing `lvimgrep` results with Vader would be appreciated.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.