@@ -656,19 +656,21 @@ getCompletions plId ideOpts CC {allModNamesAsNS, anyQualCompls, unqualCompls, qu
656
656
Down isQual -- , Down score_, _label, _detail)
657
657
658
658
uniqueCompl :: CompItem -> CompItem -> Ordering
659
- uniqueCompl x y =
660
- case compare (label x, importedFrom x, compKind x )
661
- (label y, importedFrom y, compKind y ) of
659
+ uniqueCompl candidate unique =
660
+ case compare (label candidate, compKind candidate )
661
+ (label unique, compKind unique ) of
662
662
EQ ->
663
663
-- preserve completions for duplicate record fields where the only difference is in the type
664
- -- remove redundant completions with less type info
665
- if typeText x == typeText y
666
- || isNothing (typeText x)
667
- || isNothing (typeText y)
664
+ -- remove redundant completions with less type info than the previous
665
+ if ( typeText candidate == typeText unique && isLocalCompletion unique)
666
+ -- filter global completions when we already have a local one
667
+ || not (isLocalCompletion candidate) && isLocalCompletion unique
668
668
then EQ
669
- else compare (insertText x ) (insertText y )
669
+ else compare (importedFrom candidate, insertText candidate ) (importedFrom unique, insertText unique )
670
670
other -> other
671
671
where
672
+ isLocalCompletion ci = isJust(typeText ci)
673
+
672
674
importedFrom :: CompItem -> T. Text
673
675
importedFrom (provenance -> ImportedFrom m) = m
674
676
importedFrom (provenance -> DefinedIn m) = m
0 commit comments