From 6568b3c037bdfb8211e9bc08b40e5cd8f89d0b17 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sat, 6 Nov 2021 15:03:41 +0000 Subject: [PATCH] add an example --- .../src/Development/IDE/Plugin/Completions.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ghcide/src/Development/IDE/Plugin/Completions.hs b/ghcide/src/Development/IDE/Plugin/Completions.hs index be06951f421..3b22d063a7b 100644 --- a/ghcide/src/Development/IDE/Plugin/Completions.hs +++ b/ghcide/src/Development/IDE/Plugin/Completions.hs @@ -173,6 +173,23 @@ getCompletionsLSP ide plId To allow the LSP client to reorder identifiers while preserving the relative ordering of repeated occurrences we generate sortText values that include both the label and an index denoting the relative order + + EXAMPLE + We produce completions: + x -- local + y -- local + x -- global + y -- global + + The LSP client decides to present: + y -- local + y -- global + x -- local + x -- global + + This is fine if the LSP client thinks that 'y' is more relevant than 'x'. + We are OK with that choice since the local options are presented before the global ones + -} orderedCompletions :: [CompletionItem] -> [CompletionItem] orderedCompletions = zipWith addOrder [0..]