Skip to content

incorrect suggestion for module name - missing first character of directory name #3047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andrewufrank opened this issue Jul 18, 2022 · 8 comments
Labels
component: hls-module-name-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@andrewufrank
Copy link

Your environment

Which OS do you use?

Which version of GHC do you use and how did you install it?
debian 11 actualized
ghc 8.10.7 installed with ghcup
3.6.2.0 of the Cabal library

I have in a directory Lib a file Example.hs in my project; it compiles without error.

In VScode I see a problem:

Set module name to ib.Example above the line
module Lib.Example

This is systematic and happens with all my modules.

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

Which version of HLS do you use and how did you install it?
Version: 1.69.1
Commit: b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a
Date: 2022-07-12T08:28:29.328Z
Electron: 18.3.5
Chromium: 100.0.4896.160
Node.js: 16.13.2
V8: 10.0.139.17-electron.0
OS: Linux x64 5.10.0-16-amd64

Have you configured HLS in any way (especially: a hie.yaml file)?
no hie.yaml file - rely on automatic one

The Haskell Language server with the plugin for VScode works well - except it drops the first character of the directory for a suggested module name.

For example:

I have in a directory Lib a file Example.hs in my project; it compiles without error.

In VScode I see a problem:

Set module name to ib.Example above the line
module Lib.Example

This is systematic and happens with all my modules. Is there a problem in any of my setup files and which files should I check?

Steps to reproduce

open a file, see the suggestion for a change in the module name.

Expected behaviour

no suggestion - resp. a correct suggestion (which would then not be made). correct means with the first character of the directory name. (e.g. Lib, when directory is Lib and current suggestion is ib).

Actual behaviour

Debug information

@andrewufrank andrewufrank added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Jul 18, 2022
@michaelpj
Copy link
Collaborator

@July541 you looked at the module name plugin not that long ago, maybe you have an idea?

@July541
Copy link
Collaborator

July541 commented Jul 19, 2022

@adamgundry, Thank you for your report!

I can't repro this, did I miss something? Or would you mind sharing a repo that can reproduce this?

@July541 July541 added the status: needs info Not actionable, because there's missing information label Jul 19, 2022
@andrewufrank
Copy link
Author

I am not surprised; i suppose it is a strange interaction. I currently work on
https://github.com/andrewufrank/CategoryCoreConcepts
and this shows the problem with my setupp of vscode (see above). anything else I can help?
(i have the impression I effects of caching data for HLS; for example I copy a .hs file, then rename it and fix it. still I see problems reported for the short period the file existed - long after i renamed it... - is there a simple method to clean all caches for HLS?).

@July541
Copy link
Collaborator

July541 commented Jul 19, 2022

Confirmed on your project. It's weird and can't figure out what happened with one glance. I'll check it while I have enough bandwidth (Or someone is pleased to chime in).

As I can repro, it doesn't look like about caching. FYI, I often follow the following steps to clear hls caches:

  1. Clear ghcide cache at ~/.cache/ghcide
  2. Clear hie-bios cache at ~/.cache/hie-bios
  3. Clear project's build caching by cabal clean or stack clean --full

@July541 July541 added component: hls-module-name-plugin and removed status: needs info Not actionable, because there's missing information status: needs triage labels Jul 19, 2022
@July541
Copy link
Collaborator

July541 commented Jul 19, 2022

For a reminder, implementing #1682 may be useful.

@andrewufrank
Copy link
Author

Thank you for the confirmation that you can see the same problem in my project, and special thanks for the procedures to clean the caches.

@andrewufrank
Copy link
Author

I can report that the but happens if the code is structured such that the whole directory (not just src) is

library:
     source-dirs: . 

When the code structure is changed moving the libraries into src and then adapt source-dirs: src the suggestions include the first character.
I changed my directory layout to the more common layout, but guess it would be worthwile to fix the bug for the not so common, but still legal, directory layout.
Btw, possibly linked to the bug that single character directores (e.g. in includ-dirs) are treated differently and cause error messages like not a relative path).
Thank you for a tool so helpful that I was willing to change my layout to avoid problems with the tool!

@mergify mergify bot closed this as completed in 49373fd Aug 14, 2022
@andrewufrank
Copy link
Author

Thank you!

sloorush pushed a commit to sloorush/haskell-language-server that referenced this issue Sep 12, 2022
* Make path canonicalized

* Update extra-source-files

* Replace with normalise

* Change to a more detailed log

* Comment patch detail

* 2 spaces indent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-module-name-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

3 participants