Skip to content

lsp-lens-mode errors if lenses are created in an empty buffer #2441

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

Open
nbfalcon opened this issue Dec 25, 2020 · 0 comments
Open

lsp-lens-mode errors if lenses are created in an empty buffer #2441

nbfalcon opened this issue Dec 25, 2020 · 0 comments
Assignees

Comments

@nbfalcon
Copy link
Member

nbfalcon commented Dec 25, 2020

Describe the bug
An error is thrown if a lens from an LS is to be displayed at the end of the buffer, for example because the latter is empty.

To Reproduce
0. M-x toggle-debug-on-error

  1. Create a new empty haskell file with haskell-language-server as LS (the latter sends a lens for empty buffers)
  2. Observe an error

Expected behavior
Lenses should work.

Which Language Server did you use
haskell-language-server

OS
Ubuntu 20.04 LTS

Error callstack

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  lsp-lens--update(#<overlay in no buffer>)
  lsp-lens--show(#("module Main where\n" 0 18 (local-map (keymap (mouse-1 . #f(compiled-function () (interactive nil) #<bytecode 0x15934d4ff2ed>))) mouse-face lsp-lens-mouse-face point hand action #f(compiled-function () (interactive nil) #<bytecode 0x15934d4ff2c5>) face lsp-lens-face)) 1 (#("module Main where\n" 0 18 (face lsp-lens-face action #f(compiled-function () (interactive nil) #<bytecode 0x15934d4ff2c5>) point hand mouse-face lsp-lens-mouse-face local-map (keymap (mouse-1 . #f(compiled-function () (interactive nil) #<bytecode 0x15934d4ff2ed>)))))))
  #f(compiled-function (input0) #<bytecode 0x15934d2cc461>)((0 #<hash-table equal 3/3 0x15934df2ecf9>))
  mapcar(#f(compiled-function (input0) #<bytecode 0x15934d2cc461>) ((0 #<hash-table equal 3/3 0x15934df2ecf9>)))
  -map(#f(compiled-function (input0) #<bytecode 0x15934d2cc461>) ((0 #<hash-table equal 3/3 0x15934df2ecf9>)))
  lsp-lens--display((#<hash-table equal 3/3 0x15934df2ecf9>))
  lsp-lens-show()
  funcall-interactively(lsp-lens-show)
  call-interactively(lsp-lens-show record nil)
  command-execute(lsp-lens-show record)
  counsel-M-x-action("lsp-lens-show")
  ivy-call()
  ivy-read("M-x " ("lsp-lens-show" "ccls-code-lens-mode" "lsp" "lsp-workspace-restart" "lsp-lens-mode" "dap-disconnect" "dap-ui-inspect-repl-result" "projectile-run-eshell" "counsel-projectile-rg" "toggle-debug-on-error" "dap-debug" "counsel-rg" "git-commit-elisp-text-mode" "ert" "dap-next" "calc" "lsp-treemacs-symbols" "dap-breakpoint-add" "prettify-symbols-mode" "my/save-backtrace-buffer" "my/disassemble-sexp" "lispy-mode" "+python/open-ipython-repl" "trace-function" "ptemplate-new-project" "lsp-treemacs-call-hierarchy" "untrace-function" "lsp-avy-lens" "lsp-lens-hide" "overseer-test" "package-lint-current-buffer" "emacs-lisp-mode" "run-geiser" "+lua/open-repl" "debug-on-entry" "hack-dir-local-variables-non-file-buffer" "imenu-list" "checkdoc" "dap-ui-eval-variable-in-buffer" "flyspell-buffer" "magit-abort-dwim" "+python/open-repl" "byte-compile-file" "dap-continue" "lsp-treemacs-errors-list" "lsp-disconnect" "completion-at-point" "cancel-debug-on-entry" "lsp-shutdown-workspace" "projectile-compile-project" ...) :predicate #f(compiled-function (x) #<bytecode 0x15934cda5ab9>) :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  counsel-M-x()
  funcall-interactively(counsel-M-x)
  call-interactively(counsel-M-x nil nil)
  command-execute(counsel-M-x)

The cause of the error
Note the overlay in no buffer part of the backtrace. This is because lsp-lens--ensure-at makes an overlay from point-at-bol to (1+ point-at-eol), which, clipped, equals point-at-bol because the buffer is empty, creating an overlay that covers no text. This overlay immediately dies, because the evaporate property is enabled for it:

(-doto (make-overlay (point-max) (1+ (point-max)))
  (overlay-put 'evaporate t)) ;; result: `overlay in no buffer`
@nbfalcon nbfalcon self-assigned this Dec 25, 2020
@nbfalcon nbfalcon changed the title lsp-lens-mode errors if lenses are at point-max (e.g. in an empty buffer) lsp-lens-mode errors if lenses are created in an empty buffer Dec 25, 2020
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

1 participant