Skip to content

Speed up fuzzy search #2639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions .pre-commit-config.yaml

This file was deleted.

10 changes: 7 additions & 3 deletions ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ library
dlist,
exceptions,
extra >= 1.7.4,
fuzzy,
filepath,
fingertree,
focus,
Expand Down Expand Up @@ -205,6 +204,7 @@ library
Development.IDE.Plugin.HLS.GhcIde
Development.IDE.Plugin.Test
Development.IDE.Plugin.TypeLenses
Text.Fuzzy.Parallel

other-modules:
Development.IDE.Core.FileExists
Expand All @@ -216,7 +216,6 @@ library
Development.IDE.Plugin.Completions.Logic
Development.IDE.Session.VersionCheck
Development.IDE.Types.Action
Text.Fuzzy.Parallel

ghc-options:
-Wall
Expand Down Expand Up @@ -371,6 +370,7 @@ test-suite ghcide-tests
directory,
extra,
filepath,
fuzzy,
--------------------------------------------------------------
-- The MIN_VERSION_ghc macro relies on MIN_VERSION pragmas
-- which require depending on ghc. So the tests need to depend
Expand All @@ -385,11 +385,13 @@ test-suite ghcide-tests
lsp,
lsp-types,
hls-plugin-api,
network-uri,
lens,
list-t,
lsp-test ^>= 0.14,
monoid-subclasses,
network-uri,
optparse-applicative,
parallel,
process,
QuickCheck,
quickcheck-instances,
Expand All @@ -410,6 +412,7 @@ test-suite ghcide-tests
tasty-rerun,
text,
unordered-containers,
vector,
if (impl(ghc >= 8.6) && impl(ghc < 9.2))
build-depends:
record-dot-preprocessor,
Expand All @@ -423,6 +426,7 @@ test-suite ghcide-tests
Development.IDE.Test.Runfiles
Experiments
Experiments.Types
FuzzySearch
Progress
HieDbRetry
default-extensions:
Expand Down
10 changes: 5 additions & 5 deletions ghcide/src/Development/IDE/Plugin/Completions/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import Ide.Types (CommandId (..),
import Language.LSP.Types
import Language.LSP.Types.Capabilities
import qualified Language.LSP.VFS as VFS
import Text.Fuzzy.Parallel (Scored (score_),
import Text.Fuzzy.Parallel (Scored (score),
original)

-- Chunk size used for parallelizing fuzzy matching
Expand Down Expand Up @@ -590,7 +590,7 @@ getCompletions plId ideOpts CC {allModNamesAsNS, anyQualCompls, unqualCompls, qu
$ (if T.null enteredQual then id else mapMaybe (T.stripPrefix enteredQual))
allModNamesAsNS

filtCompls = Fuzzy.filter chunkSize maxC prefixText ctxCompls "" "" (label . snd)
filtCompls = Fuzzy.filter chunkSize maxC prefixText ctxCompls (label . snd)
where

mcc = case maybe_parsed of
Expand Down Expand Up @@ -668,7 +668,7 @@ getCompletions plId ideOpts CC {allModNamesAsNS, anyQualCompls, unqualCompls, qu
return $
(fmap.fmap) snd $
sortBy (compare `on` lexicographicOrdering) $
mergeListsBy (flip compare `on` score_)
mergeListsBy (flip compare `on` score)
[ (fmap.fmap) (notQual,) filtModNameCompls
, (fmap.fmap) (notQual,) filtKeywordCompls
, (fmap.fmap.fmap) (toggleSnippets caps config) compls
Expand All @@ -681,11 +681,11 @@ getCompletions plId ideOpts CC {allModNamesAsNS, anyQualCompls, unqualCompls, qu
-- 3. In-scope completions rank next
-- 4. label alphabetical ordering next
-- 4. detail alphabetical ordering (proxy for module)
lexicographicOrdering Fuzzy.Scored{score_, original} =
lexicographicOrdering Fuzzy.Scored{score, original} =
case original of
(isQual, CompletionItem{_label,_detail}) -> do
let isLocal = maybe False (":" `T.isPrefixOf`) _detail
(Down isQual, Down score_, Down isLocal, _label, _detail)
(Down isQual, Down score, Down isLocal, _label, _detail)



Expand Down
Loading