Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion ghcide-test/exe/CompletionTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,36 @@ localCompletionTests = [

compls <- getCompletions doc (Position 0 15)
liftIO $ filter ("AAA" `T.isPrefixOf`) (mapMaybe _insertText compls) @?= ["AAAAA"]
pure ()
pure (),
completionTest
"polymorphic record dot completion"
[ "{-# LANGUAGE OverloadedRecordDot #-}"
, "module A () where"
, "data Record = Record"
, " { field1 :: Int"
, " , field2 :: Int"
, " }"
, "foo record = record.f"
]
(Position 6 21)
[("field1", CompletionItemKind_Function, "field1", True, False, Nothing)
,("field2", CompletionItemKind_Function, "field2", True, False, Nothing)
],
completionTest
"qualified polymorphic record dot completion"
[ "{-# LANGUAGE OverloadedRecordDot #-}"
, "module A () where"
, "data Record = Record"
, " { field1 :: Int"
, " , field2 :: Int"
, " }"
, "someValue = undefined"
, "foo = A.someValue.f"
]
(Position 7 19)
[("field1", CompletionItemKind_Function, "field1", True, False, Nothing)
,("field2", CompletionItemKind_Function, "field2", True, False, Nothing)
]
]

nonLocalCompletionTests :: [TestTree]
Expand Down
2 changes: 1 addition & 1 deletion ghcide/src/Development/IDE/Plugin/Completions/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ getCompletionPrefixFromRope pos@(Position l c) ropetext =
[] -> Nothing
(x:xs) -> do
let modParts = reverse $ filter (not .T.null) xs
modName = T.intercalate "." modParts
modName = if all (isUpper . T.head) modParts then T.intercalate "." modParts else ""
return $ PosPrefixInfo { fullLine = curLine, prefixScope = modName, prefixText = x, cursorPos = pos }

completionPrefixPos :: PosPrefixInfo -> Position
Expand Down
Loading