From 84061950df2a99305d2cffe2e4ab942bd18f6d16 Mon Sep 17 00:00:00 2001 From: Vitalii Ovechkin Date: Sun, 27 Sep 2020 19:50:00 +0300 Subject: [PATCH] Fix duplicated completions --- src/Development/IDE/Plugin/Completions/Logic.hs | 7 ++++--- test/exe/Main.hs | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Development/IDE/Plugin/Completions/Logic.hs b/src/Development/IDE/Plugin/Completions/Logic.hs index 78e148596..4779d7f7f 100644 --- a/src/Development/IDE/Plugin/Completions/Logic.hs +++ b/src/Development/IDE/Plugin/Completions/Logic.hs @@ -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 diff --git a/test/exe/Main.hs b/test/exe/Main.hs index e4397b424..aa06587c6 100644 --- a/test/exe/Main.hs +++ b/test/exe/Main.hs @@ -2679,6 +2679,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) ] ]