-
Notifications
You must be signed in to change notification settings - Fork 200
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
Wrong diagnostic position in the narrowed buffer #479
Comments
Does the following patch fix the issue for you? If it does, maybe we can start to think about how to create a better fix that calls save-restriction and widen less frequently, for example, just once for every received LSP message. Or maybe the overhead is negligible, I don't know. diff --git a/eglot.el b/eglot.el
index 8a1d162..ccd7f94 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1118,6 +1118,7 @@ be set to `eglot-move-to-lsp-abiding-column' (the default), and
"Convert LSP position POS-PLIST to Emacs point.
If optional MARKER, return a marker instead"
(save-excursion
+ (save-restriction (widen)
(goto-char (point-min))
(forward-line (min most-positive-fixnum
(plist-get pos-plist :line)))
@@ -1130,7 +1131,7 @@ If optional MARKER, return a marker instead"
col)
(setq col 0))
(funcall eglot-move-to-column-function col)))
- (if marker (copy-marker (point-marker)) (point))))
+ (if marker (copy-marker (point-marker)) (point)))))
(defun eglot--path-to-uri (path)
"URIfy PATH." |
@nemethf that;s 99% the right fix. I don't have any reason to believe that |
Earlier I meant to say "99% sure". It does solve @muffinmad's problem, but indeed something is hiding in that 1%, because as soon as you add the space another "unused import" gets added to the invisible first line. I think in this case it's Flymake failing to remove diagnostics out of scope. |
I meant to say "outside the region". And it wasn't Flymake's fault, it was the fault of a somewhat hackish solution to fix #159. Anyway, should be fixed now. |
…fers * eglot.el (eglot--lsp-position-to-point) (eglot-handle-notification): save-restriction and widen
…fers * eglot.el (eglot--lsp-position-to-point) (eglot-handle-notification): save-restriction and widen
* eglot.el (eglot--lsp-position-to-point) (eglot-handle-notification): save-restriction and widen #479: joaotavora/eglot#479
* eglot.el (eglot--lsp-position-to-point) (eglot-handle-notification): save-restriction and widen GitHub-reference: fix joaotavora/eglot#479
Python file:
Note eglot-warning on line 1.
Select
print()
and doC-x n n
(narrow-to-region
).Cancel selection and make an edit, e.g. add and remove space at the end of the line.
Note eglot-warning "datetime imported but unused" on the line
print()
.Not sure if this is eglot or flymake bug though.
The text was updated successfully, but these errors were encountered: