haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.61k stars 351 forks source link

Field and value completion does not work inside conditionals #4289

Open VeryMilkyJoe opened 2 weeks ago

VeryMilkyJoe commented 2 weeks ago

Cabal completion seems to not be able to complete anything inside if statements.

Here, the default completion for vscode is suggested inside an if conditional, when it should be the library section fields: image Here, the exposed modules values should be completed instead of the default vscode completions: image

The fields we are checking for completion are defined here. I think to fix this we can check the parent sections recursively instead of simply the most direct parent to figure out the stanza the cursor is located in.

fendor commented 2 weeks ago

Do we need to change the Context then?

VeryMilkyJoe commented 2 weeks ago

Do we need to change the Context then?

I don't think it is necessary to change the type of Context for this issue, since we do not care whether we are inside a conditional for the completion. We can simple set the StanzaContext to the nearest parent which is a Stanza.

fendor commented 2 weeks ago

@dyniec is taking a stab at this :confetti_ball: