Skip to content

Conversation

crtschin
Copy link

@crtschin crtschin commented Sep 5, 2025

Closes #4357.

This adds a pretty simple function for calculating the edit distance between two strings and uses it to score suggestions in completion lists. Some

  • I increased the cost of substitutions, otherwise the suggestions would very often lean towards nonsense.
  • Kind of hackily injected the Matcher that's used in scoring texts into CompleterData. Couldn't really massage that into the weightedConstantCompleter that's used for licenses.
  • This new scoring function doesn't do any filtering, so I had to adjust the cabal codeaction golden test to pick the top action per diagnostic.

@crtschin crtschin force-pushed the crtschin/codeaction-cabal-fix-typos branch from 3c4d9d8 to 53bf792 Compare September 6, 2025 10:29
@crtschin crtschin marked this pull request as ready for review September 6, 2025 12:07
Copy link
Collaborator

@fendor fendor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for taking care of this!


library
qqjfault-lang: Haskell2010
-- Import isn't supported right now.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outdated comment

@@ -18,6 +18,8 @@ import Prelude hiding (filter)
data Scored a = Scored {score :: !Int, original:: !a}
deriving (Functor, Show)

newtype Matcher a = Matcher { runMatcher :: T.Text -> [T.Text] -> [Scored a] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a comment would not hurt for why we have this :)

Perhaps all fuzzy filters should return this interface? As is, this type is only used in the cabal-plugin, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a comment would not hurt for why we have this :)

Will do.

Perhaps all fuzzy filters should return this interface? As is, this type is only used in the cabal-plugin, right?

Interesting thought. It currently is indeed yes. I'll try changing the fuzzy functions to have it and check if it's better, otherwise I'll move it to the cabal-plugin, as I just added it to not have a bare function type in CompleterData.

@fendor fendor added the status: needs review This PR is ready for review label Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs review This PR is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't use completions for cabal file codeactions
3 participants