Skip to content
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] "error drawing label" when cut a large block of code #357

Closed
1 task done
justjew opened this issue Jun 12, 2024 · 7 comments
Closed
1 task done

[BUG] "error drawing label" when cut a large block of code #357

justjew opened this issue Jun 12, 2024 · 7 comments

Comments

@justjew
Copy link

justjew commented Jun 12, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Sometimes when I cut (d) a big block of code, especially after var qwer = until ;, I am facing the following error.

error drawing label for /Users/path/to/my.dart on line 80. 
because:

If I disable flutter-tools and enable dartls using lspconfig, the error never appears.

Here's my flutter-tools config:

return {
  'akinsho/flutter-tools.nvim',
  lazy = false,
  dependencies = {
    'nvim-lua/plenary.nvim',
    'stevearc/dressing.nvim', -- optional for vim.ui.select
  },
  ft = 'dart',
  config = function()
    require('flutter-tools').setup {
      flutter_path = nil,
      flutter_lookup_cmd = 'asdf where flutter',
      statusline = {
        app_version = true,
      },
      lsp = {
        color = { -- show the derived colours for dart variables
          enabled = true, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
          background = false, -- highlight the background
          background_color = nil, -- required, when background is transparent (i.e. background_color = { r = 19, g = 17, b = 24},)
          foreground = true, -- highlight the foreground
          virtual_text = true, -- show the highlight using virtual text
          virtual_text_str = '', -- the virtual text character to highlight
        },
      },
    }
    require('flutter-tools.lsp').attach()
  end,
}

Expected Behavior

No error

Steps To Reproduce

  1. Cut a large block of some var definition from = to ;
  2. See error (sometimes)

Environment

- OS: Mac OS Sonoma 14.2.1 (23C71)
- Flutter version: 3.22.2
- Is flutter in $PATH: of course
- neovim version: v0.9.5

Anything else?

No response

@JordanllHarper
Copy link
Contributor

Not super helpful but have also seen this issue.

@CrestNiraj12
Copy link

CrestNiraj12 commented Jun 24, 2024

Any updates? This issue is so annoying. I get multiple of those if I delete/undo/cut multiple lines of code at once for each of the lines I delete and it blocks my entire view.

@akinsho
Copy link
Collaborator

akinsho commented Jun 24, 2024

For full visibility, this issue is going to need someone to get their hands dirty and dig in for a solution. As I've mentioned in other issues I'm not currently actively maintaining this and am fully dependent on users and contributors submitting PRs to fix issues like this.

@JordanllHarper
Copy link
Contributor

I'll be happy to have a look at this

@JordanllHarper
Copy link
Contributor

On investigation, it seems the line numbers we're getting (from the lsp) to draw the labels are falling out of sync with the buffer. Managed to reproduce this with some sample data.

Current theory is we get line numbers from the lsp response that don't match with the line numbers in the buffer.
The current implementation is when we come to draw the labels using nvim_buf_set_extmark, we catch any issues and notify with the error in the post.

Not sure how we want to handle this? I don't think this is the plugin's specific problem, and labels will recover pretty quickly. Perhaps only render the label if it doesn't exceed the file line length?

@sidlatau
Copy link
Collaborator

This is a good proposal. As you said labels will recover pretty quickly, so showing this label error does not add much value.

@akinsho
Copy link
Collaborator

akinsho commented Jun 25, 2024

Merged this in now which I hope fixes this issue so will close this out but if it recurs for anyone comment back on here and I'll re-open

@akinsho akinsho closed this as completed Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants