Skip to content

shebang lines are lost in exactprint #2724

@kokobd

Description

@kokobd

In hls, the exactprint doesn't preserve lines starting with #!. I've written a failing test case for this in #2725.

Your environment

Which OS do you use:

Ubuntu 20.04

Which LSP client (editor/plugin) do you use:

VSCode

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

hls itself

Compiler Version:

Currently checked on ghc 8.10.7

Steps to reproduce

Given this code:

import
#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])"
    Data.Monoid ( Monoid )

class Semigroup a => SomeData a
instance SomeData All

We can place the cursor on All and select code action "Add All to the import list of Data.Monoid", and see how the file content changes.

Expected behaviour

This is the correct code after extending the import, without losing the shebang line.

import
#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])"
    Data.Monoid ( Monoid, All )

class Semigroup a => SomeData a
instance SomeData All

Actual behaviour

This is what we are getting now.

import

    Data.Monoid ( Monoid, All )

class Semigroup a => SomeData a
instance SomeData All

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: 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