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

flymake-show-diagnostics-at-end-of-line creates a false end of line #414

Open
nehrbash opened this issue Jan 16, 2024 · 9 comments
Open

Comments

@nehrbash
Copy link

image

@nehrbash nehrbash changed the title flymake-show-diagnostics-at-end-of-line calse flymake-show-diagnostics-at-end-of-line creates a false end of line Jan 16, 2024
@nehrbash
Copy link
Author

nehrbash commented Jan 16, 2024

Sorry, I accidentally hit enter before I was done writing the ticket. The diagnostic box must already be present and this only happens with corfu-auto and the cursor also needs to be at the end of the line.

@minad
Copy link
Owner

minad commented Jan 16, 2024

Thanks for your report. The Flymake diagnostics at the end of the line are a rather new feature, not yet available on Emacs 29. I will revisit this issue after the release feature-freeze of Emacs 30. Flymake is available on ELPA, but I tend to not update builtin packages since I rely on their stability.

Regarding the point position computation and overlays at point, I am not entirely sure if we had similar issues before. Maybe some of these computation issues were even fixed in Emacs itself. The fix should be easy at least as long as we special case the Flymake overlay (temporarily hiding it for example, or disabling it when Corfu is active). I am usually not fond of such special casing, but maybe it is possible to find a generic approach.

Maybe this is also Flymake issue, if Flymake unintentionally changes the effective position of point. This could happen if the overlay is located before the point or if the before-string overlay property is used. Otherwise the position computation would not be affected.

@mekeor
Copy link

mekeor commented Jan 17, 2024

Thanks for your report. I was also about to report it right now. :D

Flymake indeed uses the before-string text-property. @minad, should I report a bug to flymake/emacs, wishing it to use the after-string text-property?

@mekeor
Copy link

mekeor commented Jan 17, 2024

After replacing before-string with after-string in the referenced code of line, then reevaluating1 that defun, fixes the issue for me.

Footnotes

  1. Use eval-defun (C-M-x) rather than eval-last-sexp (C-x C-e) since it will force a redefinition of the function definition.

@mekeor
Copy link

mekeor commented Feb 26, 2024

@minad, replacing before-string with after-string in flymake's code leads to another problem: when the flymake-error ranges until the end of a line, then the diagnostics is shown on the next line. thus, i don't think for flymake it's possible to use after-string. what do you think?

@minad
Copy link
Owner

minad commented Feb 26, 2024

Is there a way to prevent Flymake from showing the diagnostics during completion? We do the same for Eldoc already:

corfu/corfu.el

Lines 1379 to 1380 in d82bc35

(advice-add #'eldoc-display-message-no-interference-p
:before-while #'corfu--eldoc-advice)

@minad
Copy link
Owner

minad commented Sep 1, 2024

@mekeor

replacing before-string with after-string in flymake's code leads to another problem: when the flymake-error ranges until the end of a line, then the diagnostics is shown on the next line. thus, i don't think for flymake it's possible to use after-string. what do you think?

I wonder if this can be corrected if the overlay expands just right before the newline character. Then the error string should not wrap around to the next line. In any case, I think it would make sense to discuss with the new Flymake maintainer Spencer Baugh, or with the contributor who added the Flymake eol diagnostic feature.

@jdtsmith
Copy link
Collaborator

I believe flymake (like indent-bars) applies overlays on the final newline of a line, because that's the only place it can safely place them, should a completely blank line be indicated. This leads to a few strange corner cases, perhaps this is one of them.

@minad
Copy link
Owner

minad commented Feb 5, 2025

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

4 participants