Skip to content
This repository was archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Fix duplicated completions (#837)
Browse files Browse the repository at this point in the history
Co-authored-by: Vitalii Ovechkin <ovechkinve@yandex-team.ru>
  • Loading branch information
botal9 and Vitalii Ovechkin authored Sep 28, 2020
1 parent b279afb commit 85f3738
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Development/IDE/Plugin/Completions/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,10 @@ getCompletions ideOpts CC { allModNamesAsNS, unqualCompls, qualCompls, importabl
| "{-# " `T.isPrefixOf` fullLine
= filtPragmaCompls (pragmaSuffix fullLine)
| otherwise
= filtModNameCompls ++ map (toggleSnippets caps withSnippets
. mkCompl ideOpts . stripAutoGenerated) filtCompls
++ filtKeywordCompls
= let uniqueFiltCompls = nubOrdOn insertText filtCompls
in filtModNameCompls ++ map (toggleSnippets caps withSnippets
. mkCompl ideOpts . stripAutoGenerated) uniqueFiltCompls
++ filtKeywordCompls

return result

Expand Down
6 changes: 6 additions & 0 deletions test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2660,6 +2660,12 @@ nonLocalCompletionTests =
["{-# OPTIONS_GHC -Wunused-binds #-}", "module A () where", "f = Prelude.hea"]
(Position 2 15)
[ ("head", CiFunction, True, True)
],
completionTest
"duplicate import"
["module A where", "import Data.List", "import Data.List", "f = perm"]
(Position 3 8)
[ ("permutations", CiFunction, False, False)
]
]

Expand Down

0 comments on commit 85f3738

Please sign in to comment.