Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Don't return symbols with empty names
Browse files Browse the repository at this point in the history
Although LSP does not define what constitutes a valid symbol name, VS
Code's client implementation explicitly prohibits symbols with empty
names. Currently, RLS returns such symbols in many cases (for example,
the root module of a binary crate). These symbols not only fail to
parse in VS Code, but in fact cause it to throw an exception that
prevents the symbol list from being populated *at all*.

To fix this, filter out symbols with empty names before returning them
to the client.
  • Loading branch information
tchebb committed Dec 17, 2018
1 parent a0e70f1 commit 9e31676
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/actions/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl RequestAction for Symbols {

Ok(symbols
.into_iter()
.filter(|s| !s.name.is_empty())
.filter(|s| {
let range = ls_util::rls_to_range(s.span.range);
range.start != range.end
Expand Down

0 comments on commit 9e31676

Please sign in to comment.