Skip to content

Commit b7c4fd9

Browse files
committed
Fix pragma completions to prefilter
1 parent 46c3e1f commit b7c4fd9

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

haskell-language-server.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ common moduleName
220220
common pragmas
221221
if flag(pragmas) || flag(all-plugins)
222222
hs-source-dirs: plugins/default/src
223+
build-depends: fuzzy
223224
other-modules: Ide.Plugin.Pragmas
224225
cpp-options: -Dpragmas
225226

plugins/default/src/Ide/Plugin/Pragmas.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
module Ide.Plugin.Pragmas
99
(
1010
descriptor
11-
-- , commands -- TODO: get rid of this
1211
) where
1312

1413
import Control.Lens hiding (List)
@@ -25,7 +24,8 @@ import qualified Language.Haskell.LSP.Types.Lens as J
2524
import Control.Monad (join)
2625
import Development.IDE.GHC.Compat
2726
import qualified Language.Haskell.LSP.Core as LSP
28-
import qualified Language.Haskell.LSP.VFS as VFS
27+
import qualified Language.Haskell.LSP.VFS as VFS
28+
import qualified Text.Fuzzy as Fuzzy
2929

3030
-- ---------------------------------------------------------------------
3131

@@ -142,13 +142,13 @@ completion lspFuncs _ide complParams = do
142142
position = complParams ^. J.position
143143
contents <- LSP.getVirtualFileFunc lspFuncs $ toNormalizedUri uri
144144
fmap Right $ case (contents, uriToFilePath' uri) of
145-
(Just cnts, Just _path) -> do
146-
pfix <- VFS.getCompletionPrefix position cnts
147-
return $ result pfix
145+
(Just cnts, Just _path) ->
146+
result <$> VFS.getCompletionPrefix position cnts
148147
where
149148
result (Just pfix)
150149
| "{-# LANGUAGE" `T.isPrefixOf` VFS.fullLine pfix
151-
= Completions $ List $ map buildCompletion allPragmas
150+
= Completions $ List $ map buildCompletion
151+
(Fuzzy.simpleFilter (VFS.prefixText pfix) allPragmas)
152152
| otherwise
153153
= Completions $ List []
154154
result Nothing = Completions $ List []

0 commit comments

Comments
 (0)