diff --git a/cabal.project b/cabal.project index faa94671f8..3a3f7fd5e7 100644 --- a/cabal.project +++ b/cabal.project @@ -26,6 +26,11 @@ test-options: -j1 package * ghc-options: -haddock +source-repository-package + type:git + location: https://github.com/jhrcek/text-rope.git + tag: 37e808b26c8e8c862a04c985663fefd7c64335e2 + constraints: -- C++ is hard to distribute, especially on older GHCs -- See https://github.com/haskell/haskell-language-server/issues/3822 @@ -41,3 +46,4 @@ constraints: -- We want to be able to benefit from the performance optimisations -- in the future, thus: TODO: remove this flag. bitvec -simd + diff --git a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs index 867c47719a..0b1c92e08c 100644 --- a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs +++ b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs @@ -61,7 +61,7 @@ import qualified Language.LSP.VFS as VFS import Text.Fuzzy.Parallel (Scored (score), original) -import qualified Data.Text.Utf16.Rope.Mixed as Rope +import qualified Data.Text.Mixed.Rope as Rope import Development.IDE hiding (line) import Development.IDE.Spans.AtPoint (pointCommand) @@ -907,9 +907,8 @@ getCompletionPrefixFromRope pos@(Position l c) ropetext = lastMaybe = headMaybe . reverse -- grab the entire line the cursor is at - curLine <- headMaybe $ Rope.lines - $ fst $ Rope.splitAtLine 1 $ snd $ Rope.splitAtLine (fromIntegral l) ropetext - let beforePos = T.take (fromIntegral c) curLine + curLine = Rope.getLine (fromIntegral l) ropetext + beforePos = T.take (fromIntegral c) curLine -- the word getting typed, after previous space and before cursor curWord <- if | T.null beforePos -> Just "" diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index a28467e634..17e10a3e4a 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -1829,7 +1829,6 @@ test-suite hls-notes-plugin-tests main-is: NotesTest.hs build-depends: , base - , directory , filepath , haskell-language-server:hls-notes-plugin , hls-test-utils == 2.8.0.0 diff --git a/plugins/hls-notes-plugin/src/Ide/Plugin/Notes.hs b/plugins/hls-notes-plugin/src/Ide/Plugin/Notes.hs index e104a2146a..bc14c612cf 100644 --- a/plugins/hls-notes-plugin/src/Ide/Plugin/Notes.hs +++ b/plugins/hls-notes-plugin/src/Ide/Plugin/Notes.hs @@ -12,7 +12,7 @@ import Data.Maybe (catMaybes, listToMaybe, mapMaybe) import Data.Text (Text, intercalate) import qualified Data.Text as T -import qualified Data.Text.Utf16.Rope.Mixed as Rope +import qualified Data.Text.Mixed.Rope as Rope import Development.IDE hiding (line) import Development.IDE.Core.PluginUtils (runActionE, useE) import Development.IDE.Core.Shake (toKnownFiles) @@ -82,8 +82,7 @@ jumpToNote state _ param let Position l c = param ^. L.position contents <- fmap _file_text . err "Error getting file contents" =<< lift (LSP.getVirtualFile uriOrig) - line <- err "Line not found in file" (listToMaybe $ Rope.lines $ fst - (Rope.splitAtLine 1 $ snd $ Rope.splitAtLine (fromIntegral l) contents)) + let line = Rope.getLine (fromIntegral l) contents let noteOpt = listToMaybe $ mapMaybe (atPos $ fromIntegral c) $ matchAllText noteRefRegex line case noteOpt of Nothing -> pure (InR (InR Null))