Skip to content

The code action to add missing language extension adds it in the wrong place #2034

Closed
@jhrcek

Description

@jhrcek

The current behavior of this code action is problematic.
It seems to be adding the LANGUAGE pragma below the last pragma in the file.
If you happen to have some pragma like INLINE somewhere below, the LANGUAGE pragma is added after that.
But LANGUAGE pragmas are only valid before the module declaration.
See this gif illustrating the issue:
AddMissingExtension

Your environment

haskell-language-server version: 1.2.0.0 (GHC: 8.8.4) (PATH: /home/jhrcek/.local/bin/haskell-language-server) (GIT hash: 78381b8135811618101a9177ffd32102dac56b68)
Tool versions found on the $PATH
cabal:		3.4.0.0
stack:		2.7.1
ghc:		8.8.4

Which OS do you use:

Which lsp-client do you use:

Describe your project (alternative: link to the project):

Contents of hie.yaml:

Steps to reproduce

Create a haskell file like this, hover over the one and select code action Add "TupleSections"

{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE QuasiQuotes    #-}

module PI.Db.Code.Project where

tupleSection = (1,) <$> Just 2

{-# INLINE addOne #-}
addOne x = x + 1

Expected behaviour

Missing language pragma is added before the module declaration, where it is valid.

Actual behaviour

Missing language pragma is added after the last pragma in the file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: hls-pragmas-plugintype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions