Skip to content

Commit 289d75a

Browse files
committed
hls-module-name-plugin: do not suggest module names whose components start from a lower-case char
1 parent 2f5be72 commit 289d75a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs

+5-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import Control.Monad.Trans.Class (lift)
2525
import Control.Monad.Trans.Except
2626
import Control.Monad.Trans.Maybe
2727
import Data.Aeson (toJSON)
28-
import Data.Char (isLower)
28+
import Data.Char (isLower, isUpper)
2929
import Data.List (intercalate, minimumBy,
30-
stripPrefix)
30+
stripPrefix, uncons)
3131
import qualified Data.List.NonEmpty as NE
3232
import qualified Data.Map as Map
3333
import Data.Maybe (mapMaybe)
@@ -161,6 +161,9 @@ pathModuleNames recorder state normFilePath filePath
161161
moduleNameFrom =
162162
T.pack
163163
. intercalate "."
164+
-- Do not suggest names whose components start from a lower-case char,
165+
-- they are guaranteed to be malformed.
166+
. filter (maybe False (isUpper . fst) . uncons)
164167
. splitDirectories
165168
. dropExtension
166169

0 commit comments

Comments
 (0)