@@ -21,6 +21,7 @@ import Data.Hashable
21
21
import Data.HashMap.Strict (HashMap )
22
22
import qualified Data.HashMap.Strict as HashMap
23
23
import qualified Data.List.NonEmpty as NE
24
+ import qualified Data.Text as T
24
25
import qualified Data.Text.Encoding as Encoding
25
26
import qualified Data.Text.Utf16.Rope as Rope
26
27
import Data.Typeable
@@ -44,9 +45,6 @@ import qualified Language.LSP.Types as LSP
44
45
import qualified Language.LSP.Types.Lens as JL
45
46
import Language.LSP.VFS (VirtualFile )
46
47
import qualified Language.LSP.VFS as VFS
47
- import Debug.Trace (traceShowId )
48
-
49
-
50
48
data Log
51
49
= LogModificationTime NormalizedFilePath FileVersion
52
50
| LogShake Shake. Log
@@ -150,7 +148,8 @@ cabalRules recorder = do
150
148
(t, mCabalSource) <- use_ GetFileContents file
151
149
log' Debug $ LogModificationTime file t
152
150
contents <- case mCabalSource of
153
- Just sources -> pure $ Encoding. encodeUtf8 sources
151
+ Just sources ->
152
+ pure $ Encoding. encodeUtf8 sources
154
153
Nothing -> do
155
154
liftIO $ BS. readFile $ fromNormalizedFilePath file
156
155
@@ -286,11 +285,16 @@ completion _ide _ complParams = do
286
285
result (Just pfix) fp cnts
287
286
| Just ctx <- context = do
288
287
let completer = contextToCompleter " " ctx
289
- completions <- completer $ VFS. prefixText $ (traceShowId pfix)
290
- genPkgDesc <- readGenericPackageDescription silent fp
291
- pure $ J. List $ makeCompletionItems pfix genPkgDesc completions
288
+ completions <- completer filePathPfix
289
+ -- genPkgDesc <- readGenericPackageDescription silent fp
290
+ pure $ J. List $ makeCompletionItems editRange completions
292
291
| otherwise = pure $ J. List []
293
292
where
294
- pos = VFS. cursorPos pfix
295
- context = getContext pos (Rope. lines $ cnts ^. VFS. file_text)
293
+ (Position linePos charPos) = VFS. cursorPos pfix
294
+ context = getContext (Position linePos charPos) (Rope. lines $ cnts ^. VFS. file_text)
295
+ filePathPfix = getFilePathCursorPrefix pfix
296
+ editRange =
297
+ Range
298
+ (Position linePos (fromIntegral charPos - fromIntegral (T. length filePathPfix)))
299
+ (Position linePos charPos)
296
300
0 commit comments