Skip to content

Commit a15d6d3

Browse files
authored
Handle "QualifiedMode modPrefix \"\"" (#191)
Not sure if this is is correct, but on completion of: Data. My lsp integration (eglot) is sending QualifiedMode modPrefix "". I think we can just handle this as an unqualfied import. Might need an lsp expert to confirm if this is an eglot bug or a static-ls bug.
1 parent 2377afc commit a15d6d3

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/StaticLS/IDE/Completion.hs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,15 @@ getCompletion :: Context -> StaticLsM (Bool, [Completion])
277277
getCompletion cx = do
278278
mode <- getCompletionMode cx
279279
logInfo $ "mode: " <> T.pack (show mode)
280+
let importMode modPrefix = do
281+
mods <- getModules
282+
let modsWithoutPrefix = case modPrefix of
283+
Just prefix -> Maybe.mapMaybe (T.stripPrefix (prefix <> ".")) mods
284+
Nothing -> mods
285+
pure (False, textCompletion <$> modsWithoutPrefix)
280286
case mode of
281-
ImportMode modPrefix -> do
282-
mods <- getModules
283-
let modsWithoutPrefix = case modPrefix of
284-
Just prefix -> Maybe.mapMaybe (T.stripPrefix (prefix <> ".")) mods
285-
Nothing -> mods
286-
pure (False, textCompletion <$> modsWithoutPrefix)
287+
ImportMode modPrefix -> importMode modPrefix
288+
QualifiedMode modPrefix match | match == "" -> importMode (Just modPrefix)
287289
HeaderMode mod -> do
288290
let label = "module " <> mod <> " where"
289291
pure

0 commit comments

Comments
 (0)