Repository: autozimu/LanguageClient-neovim (language: rust)

Issue:
signcolumn includes symbols where no diagnostic exists (signcolumn/gutter is stale)
- Did you upgrade to latest plugin version? *Yes*
- Did you upgrade to/compile latest binary? Run shell command 
  `bin/languageclient --version` to get its version number. *Yes, 0.1.156*
- (Neovim users only) Did you check output of `:checkhealth LanguageClient`?

```
                                                                                                                                                                        
  health#LanguageClient#check                                                                                                                                           
  ========================================================================                                                                                              
    - OK: binary found: <...>/.vim/plugged/LanguageClient-neovim/bin/languageclient                                       
    - OK: languageclient 0.1.156 fb02afed15363c8879277b413b89e6ca51589e6a                                                                                               
    - OK: Floating window is supported and will be used for hover
```
- Did you check [troubleshooting]? *Yes* I haven't analysed the log file yet.

[troubleshooting]: https://github.com/autozimu/LanguageClient-neovim/blob/next/INSTALL.md#6-troubleshooting

## Describe the bug
Some symbols in the gutter / signcolumn remain after the diagnostic is cleared.
 - The quickfix window does not display a diagnostic on the line with the symbol.
 - The status line does not display any diagnostics when the cursor is on the line with the symbol.
 - Toggling the signcolumn does not fix the issue.
 - Redrawing the screen with `ctrl-l` does not fix the issue.
 - Stopping and Starting the language client does not fix the issue.
 - Restarting neovim does fix the issue.
 - I've seen it with every language server I've used (typescript-language-server, javascript-typescript-langserver, eclipse jdtl)

## Environment
- neovim/vim version (`nvim --version` or `vim --version`):
```
nvim --version
NVIM v0.4.3
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: <removed>

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info
```
- This plugin version (`git rev-parse --short HEAD`):
```
fb02afe
```
- This plugin's binary version (`bin/languageclient --version`):
```
languageclient 0.1.156 fb02afed15363c8879277b413b89e6ca51589e6a
```

## To Reproduce
```
call plug#begin('~/.local/share/nvim/plugged')

Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': 'bash install.sh',
    \ }

call plug#end()

set signcolumn=yes

let g:LanguageClient_serverCommands = {
    \ 'rust': ['npx', 'typescript-language-server', '--stdio'],
    \ }
let g:LanguageClient_loggingLevel = 'INFO'
let g:LanguageClient_virtualTextPrefix = ''
let g:LanguageClient_loggingFile =  expand('~/.local/share/nvim/LanguageClient.log')
let g:LanguageClient_serverStderr = expand('~/.local/share/nvim/LanguageServer.log')
```


Discussion / hints:
The `:sign place` list includes the phantom signs.   
`:sign unplace *` will clear all signs, including signs with corresponding diagnostics. Then signs are not replaced even when I edit lines with diagnostics or cause different diagnostics on the same lines.
Here's the cleaned up log after a session 
```
$ cat /tmp/lc.vim.log | grep 'set_sign' | sed 's|.* INFO writer-None src/rpcclient.rs:215 => None ||' | jq -c '.params | {added: .[1] | map(.id), removed: .[2] | map(.id)}'

{"added":[75001,75002,75003,75004,75005,75006],"removed":[]}
{"added":[75007,75008,75009,75010,75011],"removed":[]}
{"added":[75012],"removed":[75009,75004,75005,75006]}
{"added":[75013],"removed":[75007,75008,75010,75011,75012]}
```
`:sign place` shows [75013, 75001, 75002, 75003] which matches the state when I run the log back.
> `group_by` Return an iterable that can group iterator elements. **Consecutive** elements that map to the same key (“runs”), are assigned to the same group.

The diagnostics aren't sorted by line number, if they appear out of order (Line 0, Line 1, Line 0) signs_next will include multiple symbols for the same line.

https://github.com/autozimu/LanguageClient-neovim/blob/next/src/language_server_protocol.rs#L2539
https://docs.rs/itertools/0.8.0/itertools/trait.Itertools.html#method.group_by


Fix patch:
diff --git a/src/language_server_protocol.rs b/src/language_server_protocol.rs
index e60e95a15..4eef63d8d 100644
--- a/src/language_server_protocol.rs
+++ b/src/language_server_protocol.rs
@@ -2536,6 +2536,7 @@ impl LanguageClient {
                         diag.severity.unwrap_or(DiagnosticSeverity::Hint),
                     )
                 })
+                .sorted_by_key(|(line, _)| *line)
                 .group_by(|(line, _)| *line)
                 .into_iter()
                 .filter_map(|(_, group)| group.min_by_key(|(_, severity)| *severity))


Test patch: