@@ -177,6 +177,25 @@ completionTests =
177
177
" join"
178
178
[" {-# LANGUAGE NoImplicitPrelude #-}" ,
179
179
" module A where" , " import Control.Monad as M ()" , " import Control.Monad as N (join)" , " f = N.joi" ]
180
+ -- Regression test for https://github.com/haskell/haskell-language-server/issues/2824
181
+ , completionNoCommandTest
182
+ " explicit qualified"
183
+ [" {-# LANGUAGE NoImplicitPrelude #-}" ,
184
+ " module A where" , " import qualified Control.Monad as M (j)" ]
185
+ (Position 2 38 )
186
+ " join"
187
+ , completionNoCommandTest
188
+ " explicit qualified post"
189
+ [" {-# LANGUAGE NoImplicitPrelude, ImportQualifiedPost #-}" ,
190
+ " module A where" , " import Control.Monad qualified as M (j)" ]
191
+ (Position 2 38 )
192
+ " join"
193
+ , completionNoCommandTest
194
+ " multiline import"
195
+ [ " {-# LANGUAGE NoImplicitPrelude #-}"
196
+ , " module A where" , " import Control.Monad" , " (fore)" ]
197
+ (Position 3 9 )
198
+ " forever"
180
199
]
181
200
, testGroup " Data constructor"
182
201
[ completionCommandTest
@@ -289,11 +308,8 @@ completionNoCommandTest name src pos wanted = testSession name $ do
289
308
docId <- createDoc " A.hs" " haskell" (T. unlines src)
290
309
_ <- waitForDiagnostics
291
310
compls <- getCompletions docId pos
292
- let wantedC = find ( \ case
293
- CompletionItem {_insertText = Just x} -> wanted `T.isPrefixOf` x
294
- _ -> False
295
- ) compls
296
- case wantedC of
311
+ let isPrefixOfInsertOrLabel ci = any (wanted `T.isPrefixOf` ) [fromMaybe " " (ci ^. L. insertText), ci ^. L. label]
312
+ case find isPrefixOfInsertOrLabel compls of
297
313
Nothing ->
298
314
liftIO $ assertFailure $ " Cannot find expected completion in: " <> show [_label | CompletionItem {_label} <- compls]
299
315
Just CompletionItem {.. } -> liftIO . assertBool (" Expected no command but got: " <> show _command) $ null _command
0 commit comments