emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.76k stars 877 forks source link

(wrong-type-argument stringp nil) expand-file-name(nil) #2042

Closed zoechi closed 4 years ago

zoechi commented 4 years ago

Before logging the bug, please make sure that:

Describe the bug There seems to be a problem with lsp and recentf

To Reproduce When I try to open a file and in the completion list a file is highlighted that was opened recently, but currently is not I get the following exception.

I assume this is related to the ivy trying to show the buffer while narrowing down the completion list (before an item is chosen with Enter.

It looks like this exception was only shown because I run emacs with --debug-init. I leave it to you if this needs fixing or is "as designed".

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  expand-file-name(nil)
  lsp--path-to-uri-1(nil)
  lsp--path-to-uri(nil)
  lsp--buffer-uri()
  lsp()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook dart-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook dart-mode-hook))
  run-mode-hooks(dart-mode-hook)
  dart-mode()
  set-auto-mode-0(dart-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer channels.dart> "~/source/Customers/Ably/ably-flutter/lib/src/impl/..." nil nil "~/source/Customers/Ably/ably-flutter/lib/src/impl/..." (986999 51728))
  find-file-noselect("/home/user/source/Customers/Ably/ably-flutter/lib/...")
  counsel--switch-buffer-update-fn()
  ivy--insert-minibuffer(#("\n20200505-1443-rust.org         9.4k         Org  ..." 0 1 (read-only nil) 1 23 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight face ivy-org) 23 40 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight) 40 44 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight face error) 44 45 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight) 45 57 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight face warning) 57 58 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight) 58 73 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight face success) 73 92 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight) 92 93 (read-only nil) 93 112 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight face ivy-org) 112 132 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight) 132 136 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight face error) 136 137 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight) 137 149 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight face warning) 149 150 (read-only nil help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s   mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip) mouse-face ivy-minibuffer-match-highlight) ...))
  ivy--exhibit()
  ivy--queue-exhibit()
  read-from-minibuffer("Switch to buffer: " nil (keymap (keymap (11 . ivy-switch-buffer-kill)) keymap (36 . ivy-magic-read-file-env) (3 keymap (19 . ivy-rotate-sort) (1 . ivy-toggle-ignore) (15 . ivy-occur)) (33554464 . ivy-restrict-to-matches) (15 . hydra-ivy/body) (22 . ivy-scroll-up-command) (prior . ivy-scroll-down-command) (next . ivy-scroll-up-command) (7 . minibuffer-keyboard-quit) (right . ivy-forward-char) (32 . self-insert-command) (18 . ivy-reverse-i-search) (remap keymap (describe-mode . ivy-help) (kill-ring-save . ivy-kill-ring-save) (kill-whole-line . ivy-kill-whole-line) (kill-line . ivy-kill-line) (scroll-down-command . ivy-scroll-down-command) (scroll-up-command . ivy-scroll-up-command) (end-of-buffer . ivy-end-of-buffer) (beginning-of-buffer . ivy-beginning-of-buffer) (kill-word . ivy-kill-word) (forward-char . ivy-forward-char) (delete-char . ivy-delete-char) (backward-kill-word . ivy-backward-kill-word) (backward-delete-char-untabify . ivy-backward-delete-char) (delete-backward-char . ivy-backward-delete-char) (previous-line . ivy-previous-line) (next-line . ivy-next-line)) (9 . ivy-partial-or-done) (10 . ivy-alt-done) (27 keymap (121 . ivy-next-line) (80 . ivy-previous-history-element) (78 . ivy-next-history-element) (1 . ivy-read-action) (15 . ivy-dispatching-call) (111 . ivy-dispatching-done) (25 . ivy-insert-current-full) (105 . ivy-insert-current) (106 . ivy-yank-word) (114 . ivy-toggle-regexp-quote) (97 . ivy-toggle-marks) (16 . ivy-previous-line-and-call) (14 . ivy-next-line-and-call) (118 . ivy-scroll-down-command) (112 . previous-line) (110 . next-line) (10 . ivy-immediate-done) (13 . ivy-call)) (mouse-3 . ivy-mouse-dispatching-done) (mouse-1 . ivy-mouse-done) (down-mouse-1 . ignore) (13 . ivy-done)) nil ivy-history)
  ivy-read("Switch to buffer: " internal-complete-buffer :keymap (keymap (11 . ivy-switch-buffer-kill)) :preselect "*LSP Dart tests*" :action ivy--switch-buffer-action :matcher ivy--switch-buffer-matcher :caller ivy-switch-buffer)
  ivy-switch-buffer()
  counsel-switch-buffer()
  funcall-interactively(counsel-switch-buffer)
  call-interactively(counsel-switch-buffer nil nil)
  command-execute(counsel-switch-buffer)

Expected behavior I think lsp-mode should just do nothing instead of throwing an exception.

Which Language Server did you use lsp-dart

OS Linux

[LSP Dart] 1.14.1 (package: 20200510.2055) at 2020.08.11 @ Emacs 28.0.50
[Dart SDK] Dart SDK version: 2.10.0-4.0.dev.flutter-365525432a (be) (Sun Aug 2 19:44:23 2020 +0000) on "linux_x64"
yyoncho commented 4 years ago

Proposed fix at #2047