-
Notifications
You must be signed in to change notification settings - Fork 87
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
[BUG] LSP Message (dartls) Invalid line number #403
Comments
What's your workaround @Mike20403 ? I don't know Lua well at all but trying to look into it. |
Found out that this may only occur when yanking/pasting using a If you yank/paste from the start of your selection and manually select the last character, no error occurs. |
yep, that's what I'm suffering right now, but I feel a little inconvenient to do so, cause I frequent use ggVG to yank and copy the whole think and paste to another file with the same command "ggVG". Do you know what caused this problem? |
Hello guys, I also encountered this problem and solved it in the following way: Here is an example code: -- lua/plugins/lsp.lua
-- Dart
lsp.dartls.setup({})
local function reload_dartls_if_inactive()
local dartls_client
for _, client in ipairs(vim.lsp.get_clients()) do
if client.name == "dartls" then
dartls_client = client
break
end
end
vim.defer_fn(function()
if dartls_client and not dartls_client.is_stopped() then
return
end
if dartls_client and dartls_client.stop then
dartls_client.stop()
end
print("Restarting Dartls")
local lspconfig = require("lspconfig")
lspconfig.dartls.setup({})
end, 2000)
end
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = "*.dart",
callback = reload_dartls_if_inactive,
})
|
A decent workaround for now, cheers @bytecodevet |
Hi guys. The previous code worked quite stable. But when I tried using settings ( After a few hours of digging through the source code of flutter-tools, I finally found a solution. -- Dart
-- if you use flutter-tools lspconfig.dartls.setup you don't need to.
local function reload_dartls_if_inactive()
local dartls_client
for _, client in ipairs(vim.lsp.get_clients()) do
if client.name == "dartls" then
dartls_client = client
break
end
end
vim.defer_fn(function()
if dartls_client and not dartls_client.is_stopped() then
return
end
if dartls_client and dartls_client.stop then
dartls_client.stop()
end
require("flutter-tools.lsp").attach() -- <--- this line.
end, 2000)
end
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = "*.dart",
callback = reload_dartls_if_inactive,
}) I dug through the code for several hours, and in the end, it was just one line of code to fix it. 😅 I believe this issue has been resolved with the recent changes. Could you please close it? If further action is required, feel free to let me know. Thanks! |
perfect solution, thanks |
Is there an existing issue for this?
Current Behavior
Pasting 60-odd lines of code crashes LSP with
LSP Message (dartls) Invalid line number
.Restart neovim to continue until next paste (LSP crashes and cannot be restarted).
Expected Behavior
LSP to remain active without errors.
Steps To Reproduce
Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: