Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting special yanked scharacter in &str gives Syntax error that only goes away after :lsp-restart or undo #6591

Closed
th7mo opened this issue Apr 4, 2023 · 1 comment
Labels
C-bug Category: This is a bug

Comments

@th7mo
Copy link

th7mo commented Apr 4, 2023

Summary

I am editing a rust file with the following code:

let x = "═";

!Note that this is not a normal character, but a special box drawing unicode character!

When I navigate to the ═ character and yank it, it will give a syntax error warning when trying to paste it into the &str:
image

The error goes away when I hit undo.

Reproduction Steps

I tried this:

  1. hx .
  2. navigate to main.rs
  3. write let x = "═";
  4. yank the character in between the equal signs
  5. paste the character so it gets inserted in between the equal signs

I expected this to happen:
No error because this is valid rust code (checked with rust playground and it compiles without errors)
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b3867553cbdd613001d336a0cd19e314

Instead, this happened:
I got an syntax error that only goes away when I restart the lsp server or hit undo

Helix log

~/.cache/helix/helix.log
2023-04-04T17:22:22.950 helix_vcs [ERROR] failed to obtain current head name for /home/th7mo/.cache/helix/helix.log
2023-04-04T17:23:48.051 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":25,"line":15},"start":{"character":24,"line":15}},"text":""}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":2}}}
2023-04-04T17:23:48.061 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","diagnostics":[],"version":2}}
2023-04-04T17:23:49.618 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/signatureHelp","params":{"position":{"character":24,"line":15},"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs"}},"id":1}
2023-04-04T17:23:49.620 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":1,"result":null}
2023-04-04T17:23:49.620 helix_lsp::transport [INFO] <- null
2023-04-04T17:23:50.509 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":24,"line":15},"start":{"character":24,"line":15}},"text":"-"}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":3}}}
2023-04-04T17:23:50.520 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","diagnostics":[{"range":{"start":{"line":15,"character":26},"end":{"line":15,"character":26}},"severity":1,"code":"syntax-error","codeDescription":{"href":"https://rust-analyzer.github.io/manual.html#syntax-error"},"source":"rust-analyzer","message":"Syntax Error: expected field name or number"}],"version":3}}
2023-04-04T17:23:51.237 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/signatureHelp","params":{"position":{"character":24,"line":15},"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs"}},"id":2}
2023-04-04T17:23:51.237 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":25,"line":15},"start":{"character":24,"line":15}},"text":""}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":4}}}
2023-04-04T17:23:51.240 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":2,"result":null}
2023-04-04T17:23:51.241 helix_lsp::transport [INFO] <- null
2023-04-04T17:23:51.244 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","diagnostics":[],"version":4}}
2023-04-04T17:23:51.389 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":24,"line":15},"start":{"character":24,"line":15}},"text":"="}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":5}}}
2023-04-04T17:23:51.398 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","diagnostics":[{"range":{"start":{"line":15,"character":26},"end":{"line":15,"character":26}},"severity":1,"code":"syntax-error","codeDescription":{"href":"https://rust-analyzer.github.io/manual.html#syntax-error"},"source":"rust-analyzer","message":"Syntax Error: expected field name or number"}],"version":5}}
2023-04-04T17:23:56.119 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":25,"line":15},"start":{"character":25,"line":15}},"text":"="}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":6}}}
2023-04-04T17:23:57.373 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":26,"line":15},"start":{"character":25,"line":15}},"text":""}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":7}}}
2023-04-04T17:23:57.608 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":25,"line":15},"start":{"character":24,"line":15}},"text":""}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":8}}}
2023-04-04T17:23:57.620 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","diagnostics":[],"version":8}}
2023-04-04T17:24:02.059 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":24,"line":15},"start":{"character":24,"line":15}},"text":"="}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":9}}}
2023-04-04T17:24:02.068 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","diagnostics":[{"range":{"start":{"line":15,"character":26},"end":{"line":15,"character":26}},"severity":1,"code":"syntax-error","codeDescription":{"href":"https://rust-analyzer.github.io/manual.html#syntax-error"},"source":"rust-analyzer","message":"Syntax Error: expected field name or number"}],"version":9}}
2023-04-04T17:24:03.534 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":25,"line":15},"start":{"character":24,"line":15}},"text":""}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":10}}}
2023-04-04T17:24:03.543 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","diagnostics":[],"version":10}}
2023-04-04T17:24:14.874 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":31,"line":17},"start":{"character":31,"line":17}},"text":"="}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":11}}}
2023-04-04T17:24:15.767 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":32,"line":17},"start":{"character":31,"line":17}},"text":""}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":12}}}
2023-04-04T17:24:18.041 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":25,"line":17},"start":{"character":25,"line":17}},"text":"═"}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":13}}}
2023-04-04T17:24:18.068 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","diagnostics":[{"range":{"start":{"line":17,"character":33},"end":{"line":17,"character":33}},"severity":1,"code":"syntax-error","codeDescription":{"href":"https://rust-analyzer.github.io/manual.html#syntax-error"},"source":"rust-analyzer","message":"Syntax Error: expected field name or number"},{"range":{"start":{"line":17,"character":33},"end":{"line":17,"character":33}},"severity":1,"code":"syntax-error","codeDescription":{"href":"https://rust-analyzer.github.io/manual.html#syntax-error"},"source":"rust-analyzer","message":"Syntax Error: expected SEMICOLON"},{"range":{"start":{"line":17,"character":33},"end":{"line":17,"character":33}},"severity":1,"code":"syntax-error","codeDescription":{"href":"https://rust-analyzer.github.io/manual.html#syntax-error"},"source":"rust-analyzer","message":"Syntax Error: expected expression"}],"version":13}}
2023-04-04T17:24:19.445 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":26,"line":17},"start":{"character":25,"line":17}},"text":""}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":14}}}
2023-04-04T17:24:19.455 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","diagnostics":[],"version":14}}
2023-04-04T17:26:25.361 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":24,"line":15},"start":{"character":24,"line":15}},"text":"═"}],"textDocument":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","version":15}}}
2023-04-04T17:26:25.370 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/th7mo/dev/rust/logic/src/main.rs","diagnostics":[{"range":{"start":{"line":15,"character":26},"end":{"line":15,"character":26}},"severity":1,"code":"syntax-error","codeDescription":{"href":"https://rust-analyzer.github.io/manual.html#syntax-error"},"source":"rust-analyzer","message":"Syntax Error: expected field name or number"},{"range":{"start":{"line":15,"character":26},"end":{"line":15,"character":26}},"severity":1,"code":"syntax-error","codeDescription":{"href":"https://rust-analyzer.github.io/manual.html#syntax-error"},"source":"rust-analyzer","message":"Syntax Error: expected SEMICOLON"},{"range":{"start":{"line":15,"character":26},"end":{"line":15,"character":26}},"severity":1,"code":"syntax-error","codeDescription":{"href":"https://rust-analyzer.github.io/manual.html#syntax-error"},"source":"rust-analyzer","message":"Syntax Error: expected expression"}],"version":15}}

Platform

WSL2 on Windows

Terminal Emulator

Windows Terminal

Helix Version

helix 23.03

@th7mo th7mo added the C-bug Category: This is a bug label Apr 4, 2023
@th7mo th7mo changed the title Pasting yanked character in &str gives Syntax error that only goes away after :lsp-restart Pasting special yanked scharacter in &str gives Syntax error that only goes away after :lsp-restart or undo Apr 4, 2023
@th7mo th7mo changed the title Pasting special yanked scharacter in &str gives Syntax error that only goes away after :lsp-restart or undo Pasting special yanked scharacter in &str gives Syntax error that only goes away after :lsp-restart or undo Apr 4, 2023
@pascalkuthe
Copy link
Member

Rust analyzer only updates most diagnostics on save so you need to save the file for that diagnostic to update. From your lognitnlooks like you never saved.

Generally language specific bugs like these are.never related yo.helix itself and instead the language server for the various languages (rust-analyzer in this vase). Helix doenst implement any language specific logic.

#6447 improves this somewhat with better tracking for these kinds of "updated on save diagnostics" but the same issue exists in vscode so it's really just a trick i added to work around the LS (rust-analyzer) shortcomings.

@pascalkuthe pascalkuthe converted this issue into discussion #6596 Apr 5, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

2 participants