Skip to content

Conversation

kinnison
Copy link
Contributor

Find all similar lints and allow applying them all across the document in one code action. This should fix #998.

Issues

Fixes #998

Description

This adds additional quickfix actions which perform a particular lint suggestion document-wide. The intent being to resolve #998 in a reasonable fashion.

Demo

replace-all

How Has This Been Tested?

I added the locally built harper-ls to my helix configuration and tested across a variety of markdown documents doing global replacements of the same and differing lengths, including situations where the action was similar but the lint different (eg. replacing a double-space in the middle of a sentence vs. after a full-stop). All seemed good.

Also, cargo test --all didn't complain.

Right now I'm not particularly pleased with how this is implemented, so I'm interested in the views of @elijah-potter in particular. I feel there must be a neater way to do this.

Checklist

  • I have performed a self-review of my own code
  • I have added tests to cover my changes

Find all similar lints and allow applying them all across the document
in one code action. This should fix Automattic#998.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
@elijah-potter
Copy link
Collaborator

Here's how I see this.

We don't want to overwhelm the user with options. It should not take a long time for them to find the code action they're looking for. The more reading they have to do, the longer it will take for that to happen. To that end, we want to show a just a few, high-impact code actions at a time.

If we want to stick to surfacing this functionality via a code action, we should show at most one additional action at a time when a user hovers. In other words, if the user hovers over an error related to too many spaces, we should show one code action to fix the specific location, and one to fix all in the document. If they hover over a spelling mistake, we should show the same 3 that we always do, but only one additional one to apply the most likely suggestion for the whole document.

From an architectural standpoint, I'd love to see the logic contained in this PR moved to harper-core so we can implement similar functionality for other platforms.

@kinnison
Copy link
Contributor Author

Fair enough - I'll give this some deeper thought, thanks for that review @elijah-potter - Are the suggestions in the lint in order of likelihood of correctness?

@elijah-potter
Copy link
Collaborator

elijah-potter commented Aug 25, 2025

Are the suggestions in the lint in order of likelihood of correctness?

If you have access to the full Lint struct, you should use the one with the lowest priority.

@elijah-potter
Copy link
Collaborator

I misunderstood. Yes, go with just the first suggestion.

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

Successfully merging this pull request may close these issues.

Add a "fix all" button for repeated errors in a document.
2 participants