lsp-mode
lsp-mode copied to clipboard
"replace-match-maybe-edit: Match data clobbered by buffer modification hooks" with lsp-clangd
This is basically the same issue as #1293 and #2081, this time when using query-replace in a C++ buffer with the lsp-clangd backend enabled. To reproduce: Use (c-c++ :variables c-c++-backend 'lsp-clangd)
in Spacemacs' dotspacemacs-configuration-layers
and do a query-replace. (lsp-mode-20201008.1601)
Probably yet another missing save-match-data
, but I've got no clue where to add this...
can you provide callstack?
can you provide callstack?
How can I produce one? The *Messages*
buffer contains only a one-line message as seen in the topic of this issue.
In the Report bug template
there is an instruction on how to do that: https://github.com/emacs-lsp/lsp-mode/blob/master/.github/ISSUE_TEMPLATE/bug_report.md
Debugger entered--Lisp error: (error "Match data clobbered by buffer modification hooks")
replace-match("main_reply_queue_" nil t)
replace-match-maybe-edit("main_reply_queue_" nil t nil (5915 5921 #<buffer main.cc>) nil)
perform-replace(#("queue_" 0 5 (face font-lock-variable-name-face) 5 6 (rear-nonsticky t face font-lock-variable-name-face)) "main_reply_queue_" t nil nil nil nil nil nil nil nil)
query-replace(#("queue_" 0 5 (face font-lock-variable-name-face) 5 6 (rear-nonsticky t face font-lock-variable-name-face)) "main_reply_queue_" nil nil nil nil nil)
funcall-interactively(query-replace #("queue_" 0 5 (face font-lock-variable-name-face) 5 6 (rear-nonsticky t face font-lock-variable-name-face)) "main_reply_queue_" nil nil nil nil nil)
call-interactively(query-replace nil nil)
command-execute(query-replace)
Is any info still missing? I don't think so, but I can't remove the need-info
label, because I'm not a project owner...
The issue is still there with the latest lsp-mode-20201027.850. Is there anything else I can do to help debugging this? A broken query-replace is quite annoying in day-to-day work. :cry: Everything else is very usable, so this is a pity...
I am unable to reproduce with the provided info. Also, I do not see lsp-mode in the error callstack. Are you able to reproduce with lsp-start-plain.el?
I am unable to reproduce with the provided info. Also, I do not see lsp-mode in the error callstack.
Neither do I, but nevertheless I am relatively sure that lsp-mode is the culprit: My current workaround is to switch to any non-lsp-mode (e.g. fundamental), do the query-replace, and switch back to c/c++-mode.
I am using Spacemacs (development branch, updating almost daily) with Emacs 27.1. The relevant snippet from my .spacemacs
in the dotspacemacs-configuration-layers
part:
(c-c++ :variables
c-c++-backend 'lsp-clangd
c-c++-default-mode-for-headers 'c++-mode
lsp-clients-clangd-executable "clangd-11"
company-clang-executable "clang-11"
clang-format-executable "clang-format-11")
Are you able to reproduce with lsp-start-plain.el?
How can I do that? I'm happy to try, but I've never heard of lsp-start-plain.el...
It really looks like another save-match-data
is missing somewhere in lsp-mode, but I can't really guess where. Can you give me some hints/places where I can try to add this?
How can I do that? I'm happy to try, but I've never heard of lsp-start-plain.el...
The instructions are in the bug template.
It really looks like another
save-match-data
is missing somewhere in lsp-mode, but I can't really guess where. Can you give me some hints/places where I can try to add this?
I have no clue.
My current workaround is to switch to any non-lsp-mode (e.g. fundamental), do the query-replace, and switch back to c/c++-mode.
Try lsp-disconnect
The relevant snippet from my .spacemacs in the dotspacemacs-configuration-layers part:
I am using spacemacs as well. The issue might be from a different layer/setting.
I am quite sure by now that the culprit is the "info box" (don't know what it is called in lsp-mode) popping up in the upper right, showing information like the signature/comments/... of the C++ entity below the cursor:
- If this pops up during query-replace, the match data is clobbered.
- If it pops up during repeatedly pressing M-d (kill-word), the kill ring is somehow broken (it did not accumulate the consecutive kills anymore).
- If it pops up during incremental search (isearch-forward, C-s), it breaks the "search again" functionality of C-s, i.e. you have to press C-s an additional time.
All of this seems to imply that the "info box" incorrectly modifies various global state which should better be left untouched.
To see all those bugs you need a working C++ project where the "info box" actually pops up all the time when the cursor is over a C++ entity. This means that you need a compile-commands.json
file, have set the project root correctly etc. This might explain why you don't see the bugs I am describing. But setting up such a project should not be a problem for someone who has written lsp-clangd.el
. :wink: I am a bit clueless how to give more hints with a simpler setup, but given the amount of bugs associated with the "info box", it shouldn't be too hard to reproduce on your side. :thinking:
One final thing: I update my Spacemacs packages almost every day, so the problem should be reproducible in lsp-mode's HEAD, I guess. Currently my Spacemacs uses .emacs.d/elpa/27.1/develop/lsp-mode-20201103.2013
.
Still an issue for me on lsp-mode-20210330.1510
It seems to be due to the "info box" that svenpanne mentioned.
My workaround is to use these functions to disable the info box (lsp-ui-doc-mode
) for all buffers before doing a rename,
and then reenable when I'm done renaming.
(defun w/disable-doc ()
(interactive)
(setq lsp-ui-doc-enable nil)
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(lsp-ui-doc-mode -1))))
(defun w/enable-doc ()
(interactive)
(setq lsp-ui-doc-enable 1)
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(lsp-ui-doc-mode 1))))
Hope it's useful to someone. p.s. lsp-mode is amazing, don't know how I lived without it. Thanks for all your hard work on it.
Just to bring more evidence to the problem, I'm having this exact same problem using lsp-mode
for elixir
.
I tried this last snippet from @wkenyon but didn't work to me, the only workaround that was working is to change the major mode to something else, do a query-replace
and then go back to the elixir-mode
.
Still an issue to me on LSP :: lsp-mode 20220429.647, Emacs 27.2, gnu/linux
Hey folks, just to give you some feedback, my problem wasn't related to lsp-mode
, was related to the auto-highlight-symbol
package.
Any updates on this issue? I'm still seeing errors despite disabling lsp-mode (clangd) and highlight-symbol-mode (similar to auto highlight symbol).