zioroboco / nu-ls.nvim

A null-ls source providing language server features for the nushell language in neovim
MIT License
15 stars 1 forks source link

Race condition in async completions with debounce #10

Open zioroboco opened 1 year ago

zioroboco commented 1 year ago

Since the introduction of the debounce timer for completions in #7, typing quickly can sometimes cause nu to return an error like the following:

thread 'main' panicked at 'assertion failed: self.is_char_boundary(idx)', /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/alloc/src/string.rs:1532:9

This looks similar to errors I've seen before when asking nu to generate completions for a cursor position beyond the end of the file.

I suspect this might be caused by a race condition, likely from differences between the temporary file that nu's being asked to generate completions against and the cursor position reported by null-ls.

zioroboco commented 1 year ago

I've bumped the debounce time for completions in https://github.com/zioroboco/nu-ls.nvim/commit/6a7205d96ad9f678b2c411a2c571d904f55d1f02 so this is probably happening a lot more now. The errors themselves are being suppressed, so we'll wait and see if it causes any trouble in practice.