Skip to content

Don't use completions for cabal file codeactions #4357

@VeryMilkyJoe

Description

@VeryMilkyJoe
Collaborator

At the moment, codeactions (PR: #3273) in cabal files put a cursor at the end of the misspelled word and then suggest any possible completions.
This is not ideal, since words that have a typo early on will not trigger the correct codeaction.
We should use a different algorithm for the fuzzy matching than completions to better support the semantics of the codeactions.

Activity

added
HackathonThis issue is suitable for hackathon sessions
and removed on Aug 6, 2024
JadarTheObscurity

JadarTheObscurity commented on May 13, 2025

@JadarTheObscurity

Hi! I’m very new to Haskell and to contributing to open source. I came across this issue and thought it would be a great opportunity to learn more about the ecosystem.

I’ve implemented a version of the Smith-Waterman algorithm for fuzzy matching under Text.Fuzzy.Parallel, and I’m interested in exploring how it could help improve code actions in cabal files, as suggested in this issue.

However, I’m not sure which part of the codebase is responsible for the in-editor highlighting of the matched string (as shown in the image below). Could someone point me to the relevant modules or files I should look into?

Since this is both my first time working with a functional language and contributing to a Haskell project, any advice or suggestions on how to approach this issue would be very much appreciated!

Image

fendor

fendor commented on May 13, 2025

@fendor
Collaborator

Hi, thank you for your interest!

However, I’m not sure which part of the codebase is responsible for the in-editor highlighting of the matched string (as shown in the image below). Could someone point me to the relevant modules or files I should look into?

I believe the highlighting is done automatically by VSCode, so it is not something you can control.
Or are you asking for the location where these strings are produced?

JadarTheObscurity

JadarTheObscurity commented on May 13, 2025

@JadarTheObscurity
fendor

fendor commented on May 13, 2025

@fendor
Collaborator

This is the entry point for the completions https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal.hs#L133 (which is what you see in the screenshot, which is not what this issue is about) and https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal.hs#L135 is the entry point for code actions that correct typos in field names.

JadarTheObscurity

JadarTheObscurity commented on May 13, 2025

@JadarTheObscurity
fendor

fendor commented on May 13, 2025

@fendor
Collaborator

The easiest way to debug is traceShowM and using the logger. You can enable DEBUG log messages by passing --debug to the serverExtraArgs in VSCode.

Another good way is to run a single test, for example cabal test hls-cabal-plugin-tests --test-options='-p "Code Actions - Can fix field names"' which runs the test here https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-cabal-plugin/test/Main.hs#L189

That's often much faster than the manual testing. Same tips apply though, logging and trace* are the way to go to debug Haskell right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @fendor@VeryMilkyJoe@JadarTheObscurity

        Issue actions

          Don't use completions for cabal file codeactions · Issue #4357 · haskell/haskell-language-server