From 2618113ef4934868714bf38efc1479aae0d05927 Mon Sep 17 00:00:00 2001 From: Arnaud BOEGLIN Date: Mon, 17 Jun 2024 19:36:59 +0200 Subject: [PATCH] fix: use correct range for autocompletion --- compiler/main/Run/LanguageServer.hs | 4 ++-- madlib.cabal | 2 +- package.yaml | 2 +- pkg/package.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/main/Run/LanguageServer.hs b/compiler/main/Run/LanguageServer.hs index 3e590742..0b53f26f 100644 --- a/compiler/main/Run/LanguageServer.hs +++ b/compiler/main/Run/LanguageServer.hs @@ -106,7 +106,7 @@ handlers state autocompletionState = mconcat let fileContent = T.unpack . virtualFileText <$> file case fileContent of Just content -> do - let foundLine = take (col + 1) $ lines content !! line + let foundLine = take col $ lines content !! line suggestions <- getAutocompletionSuggestions autocompletionState (Loc 0 (line + 1) (col + 1)) (uriToPath uri) content -- https://github.com/haskell/lsp/blob/76b86d54040cfa6c8306433a29404fa6402a5f69/lsp-types/src/Language/LSP/Types/Completion.hs @@ -1178,7 +1178,7 @@ completionSuggestionsTask :: Loc -> FilePath -> String -> Rock.Task Query.Query completionSuggestionsTask loc@(Loc _ line col) modulePath moduleContent = do (typedAst, env) <- Rock.fetch $ Query.SolvedASTWithEnv modulePath - let foundLine = take col $ lines moduleContent !! (line - 1) + let foundLine = take (col - 1) $ lines moduleContent !! (line - 1) let autocompletionKind = computeAutocompletionKind (reverse foundLine) let topLevelExp = findTopLevelExp loc (Slv.aexps typedAst) diff --git a/madlib.cabal b/madlib.cabal index 32b3d9f4..5810a29b 100644 --- a/madlib.cabal +++ b/madlib.cabal @@ -5,7 +5,7 @@ cabal-version: 2.0 -- see: https://github.com/sol/hpack name: madlib -version: 0.24.0 +version: 0.24.1 description: Please see the README on GitHub at homepage: https://github.com/madlib-lang/madlib#readme bug-reports: https://github.com/madlib-lang/madlib/issues diff --git a/package.yaml b/package.yaml index a3efc23d..564c92a4 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: madlib -version: 0.24.0 +version: 0.24.1 github: "madlib-lang/madlib" license: BSD3 author: "Arnaud Boeglin, Brekk Bockrath" diff --git a/pkg/package.json b/pkg/package.json index b1d7f9f4..2938c11d 100644 --- a/pkg/package.json +++ b/pkg/package.json @@ -1,6 +1,6 @@ { "name": "@madlib-lang/madlib", - "version": "0.24.0", + "version": "0.24.1", "main": "./src/run.js", "bin": { "madlib": "src/run.js"