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 <[email protected]>
@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.

@elijah-potter
Copy link
Collaborator

@kinnison, do you have any updates for us on this?

@kinnison
Copy link
Contributor Author

kinnison commented Nov 9, 2025

@kinnison, do you have any updates for us on this?

I'm so sorry for the radio silence - I've been in the process of buying a new house so I've not had any time to work on this patch.

I think I need to just work out the neatest way to limit to the best suggestion; but I've not had time to look at the code since late august :(

I'd be comfortable if you just wanted to chuck away my patch and redo-from-start; or if you're happy waiting then I'll see what I can do in a week or two.

@elijah-potter
Copy link
Collaborator

Absolutely no worries! Buying a house is a huge step in life. Please focus on that.

I think we should keep this PR open so it remains visible to potential contributors. I'm going to change it to a draft, however. When you've had a chance to look at the problem once more, mark it as ready for review. Thanks again for all the work!

@elijah-potter elijah-potter marked this pull request as draft November 10, 2025 20:22
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