Skip to content

Commit 90d8d2f

Browse files
committed
Only compare line numbers when checking cursor presence
1 parent 4e904c8 commit 90d8d2f

2 files changed

Lines changed: 29 additions & 29 deletions

File tree

ghcide-test/exe/CompletionTests.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,7 @@ contextCompletionTests =
523523
doc <- openDoc "A.hs" "haskell"
524524
_ <- waitForDiagnostics
525525
compls <- getCompletions doc (Position 1 3)
526-
let importSnippets = [ c | c@CompletionItem{..} <- compls
527-
, _kind == Just CompletionItemKind_Snippet
528-
, _label == "import" ]
526+
let importSnippets = filterSnippetsLabel "import" compls
529527
liftIO $ length importSnippets @?= 4
530528

531529
, completionTest "no import snippet past a declaration"
@@ -594,9 +592,7 @@ contextCompletionTests =
594592
doc <- openDoc "A.hs" "haskell"
595593
_ <- waitForDiagnostics
596594
compls <- getCompletions doc (Position 4 13)
597-
let snippets = [ c | c@CompletionItem{..} <- compls
598-
, _kind == Just CompletionItemKind_Snippet
599-
, _label == "import" ]
595+
let snippets = filterSnippetsLabel "import" compls
600596
liftIO $ snippets @?= []
601597

602598
, testSessionSingleFile "top level excludes regular completions" "A.hs"
@@ -671,9 +667,7 @@ contextCompletionTests =
671667
doc <- openDoc "A.hs" "haskell"
672668
_ <- waitForDiagnostics
673669
compls <- getCompletions doc (Position 3 15) -- after "imp" in " helper = imp"
674-
let snippets = [ c | c@CompletionItem{..} <- compls
675-
, _kind == Just CompletionItemKind_Snippet
676-
, _label == "import" ]
670+
let snippets = filterSnippetsLabel "import" compls
677671
liftIO $ snippets @?= []
678672

679673
, completionTest
@@ -733,6 +727,12 @@ contextCompletionTests =
733727
(Position 5 19) -- after "Xxx" in " let helper :: Xxx"
734728
[("Xxxtype", CompletionItemKind_Struct, "Xxxtype", False, True, Nothing)]
735729
]
730+
where
731+
filterSnippetsLabel l snippets =
732+
[ c | c@CompletionItem{..} <- snippets
733+
, _kind == Just CompletionItemKind_Snippet
734+
, _label == l
735+
]
736736

737737
completionDocTests :: [TestTree]
738738
completionDocTests =

plugins/hls-refactor-plugin/test/Main.hs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -189,30 +189,30 @@ completionTests =
189189
, testGroup "Data constructor"
190190
[ completionCommandTest
191191
"not imported"
192-
["module A where", "import Text.Printf ()", "ZeroPad"]
193-
(Position 2 4)
192+
["module A where", "import Text.Printf ()", "a = ZeroPad"]
193+
(Position 2 8)
194194
"ZeroPad"
195-
["module A where", "import Text.Printf (FormatAdjustment (ZeroPad))", "ZeroPad"]
195+
["module A where", "import Text.Printf (FormatAdjustment (ZeroPad))", "a = ZeroPad"]
196196
, completionCommandTest
197197
"parent imported abs"
198-
["module A where", "import Text.Printf (FormatAdjustment)", "ZeroPad"]
199-
(Position 2 4)
198+
["module A where", "import Text.Printf (FormatAdjustment)", "a = ZeroP"]
199+
(Position 2 8)
200200
"ZeroPad"
201-
["module A where", "import Text.Printf (FormatAdjustment (ZeroPad))", "ZeroPad"]
201+
["module A where", "import Text.Printf (FormatAdjustment (ZeroPad))", "a = ZeroP"]
202202
, completionNoCommandTest
203203
"parent imported all"
204-
["module A where", "import Text.Printf (FormatAdjustment (..))", "ZeroPad"]
205-
(Position 2 4)
204+
["module A where", "import Text.Printf (FormatAdjustment (..))", "a = ZeroP"]
205+
(Position 2 8)
206206
"ZeroPad"
207207
, completionNoCommandTest
208208
"already imported"
209-
["module A where", "import Text.Printf (FormatAdjustment (ZeroPad))", "ZeroPad"]
210-
(Position 2 4)
209+
["module A where", "import Text.Printf (FormatAdjustment (ZeroPad))", "a = ZeroP"]
210+
(Position 2 8)
211211
"ZeroPad"
212212
, completionNoCommandTest
213213
"function from Prelude"
214-
["module A where", "import Data.Maybe ()", "Nothing"]
215-
(Position 2 4)
214+
["module A where", "import Data.Maybe ()", "a = Nothi"]
215+
(Position 2 8)
216216
"Nothing"
217217
, completionCommandTest
218218
"type operator parent"
@@ -224,20 +224,20 @@ completionTests =
224224
, testGroup "Record completion"
225225
[ completionCommandTest
226226
"not imported"
227-
["module A where", "import Text.Printf ()", "FormatParse"]
228-
(Position 2 10)
227+
["module A where", "import Text.Printf ()", "a :: FormatParse"]
228+
(Position 2 14)
229229
"FormatParse"
230-
["module A where", "import Text.Printf (FormatParse)", "FormatParse"]
230+
["module A where", "import Text.Printf (FormatParse)", "a :: FormatParse"]
231231
, completionCommandTest
232232
"parent imported"
233-
["module A where", "import Text.Printf (FormatParse)", "FormatParse"]
234-
(Position 2 10)
233+
["module A where", "import Text.Printf (FormatParse)", "a = FormatParse"]
234+
(Position 2 14)
235235
"FormatParse"
236-
["module A where", "import Text.Printf (FormatParse (FormatParse))", "FormatParse"]
236+
["module A where", "import Text.Printf (FormatParse (FormatParse))", "a = FormatParse"]
237237
, completionNoCommandTest
238238
"already imported"
239-
["module A where", "import Text.Printf (FormatParse (FormatParse))", "FormatParse"]
240-
(Position 2 10)
239+
["module A where", "import Text.Printf (FormatParse (FormatParse))", "a = FormatP"]
240+
(Position 2 14)
241241
"FormatParse"
242242
]
243243
, testGroup "Package completion"

0 commit comments

Comments
 (0)