haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Don't use completions for cabal file codeactions

Open VeryMilkyJoe opened this issue 1 year ago • 6 comments

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.

VeryMilkyJoe avatar Jul 11 '24 12:07 VeryMilkyJoe

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

JadarTheObscurity avatar May 13 '25 06:05 JadarTheObscurity

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?

fendor avatar May 13 '25 07:05 fendor

Yeah, I would like to know which function produces the final result that shows in the suggested completion

2025年5月13日(火) 午後3:02 fendor @.***>:

fendor left a comment (haskell/haskell-language-server#4357) https://github.com/haskell/haskell-language-server/issues/4357#issuecomment-2875279195

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?

— Reply to this email directly, view it on GitHub https://github.com/haskell/haskell-language-server/issues/4357#issuecomment-2875279195, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOZLJ4L4S6AD3O5ZITFRWZT26GKIHAVCNFSM6AAAAAB47UMO2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQNZVGI3TSMJZGU . You are receiving this because you commented.Message ID: @.***>

JadarTheObscurity avatar May 13 '25 07:05 JadarTheObscurity

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.

fendor avatar May 13 '25 09:05 fendor

Ok, I would take a look inside those functions. Also, do you have any suggestions on how to debug while the language server is running? I would like to see a list of suggested keywords with their score. I am using Windows 11 + vscode

On Tue, May 13, 2025 at 5:43 PM fendor @.***> wrote:

fendor left a comment (haskell/haskell-language-server#4357) https://github.com/haskell/haskell-language-server/issues/4357#issuecomment-2875778310

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.

— Reply to this email directly, view it on GitHub https://github.com/haskell/haskell-language-server/issues/4357#issuecomment-2875778310, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOZLJ4LQHIWUMGT7XY47RL326G5EBAVCNFSM6AAAAAB47UMO2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQNZVG43TQMZRGA . You are receiving this because you commented.Message ID: @.***>

JadarTheObscurity avatar May 13 '25 13:05 JadarTheObscurity

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.

fendor avatar May 13 '25 13:05 fendor