diff --git a/ghcide/bench/lib/Experiments.hs b/ghcide/bench/lib/Experiments.hs index 4b3396d7db..3007d8d242 100644 --- a/ghcide/bench/lib/Experiments.hs +++ b/ghcide/bench/lib/Experiments.hs @@ -187,7 +187,7 @@ experiments = let edit :: TextDocumentContentChangeEvent =TextDocumentContentChangeEvent { _range = Just Range {_start = bottom, _end = bottom} , _rangeLength = Nothing, _text = t} - bottom = Position maxBound 0 + bottom = Position maxBoundUinteger 0 t = T.unlines ["" ,"holef :: [Int] -> [Int]" @@ -625,3 +625,8 @@ searchSymbol doc@TextDocumentIdentifier{_uri} fileContents pos = do _ -> return False checkCompletions pos = not . null <$> getCompletions doc pos + +-- | We don't have a uinteger type yet. So hardcode the maxBound of uinteger, 2 ^ 31 - 1 +-- as a constant. +maxBoundUinteger :: Int +maxBoundUinteger = 2147483647 diff --git a/ghcide/src/Development/IDE/LSP/Outline.hs b/ghcide/src/Development/IDE/LSP/Outline.hs index 22e1a3fa85..44714f23d7 100644 --- a/ghcide/src/Development/IDE/LSP/Outline.hs +++ b/ghcide/src/Development/IDE/LSP/Outline.hs @@ -48,7 +48,13 @@ moduleOutline ideState DocumentSymbolParams{ _textDocument = TextDocumentIdentif (defDocumentSymbol l :: DocumentSymbol) { _name = pprText m , _kind = SkFile - , _range = Range (Position 0 0) (Position maxBound 0) -- _ltop is 0 0 0 0 + , _range = Range (Position 0 0) (Position 2147483647 0) -- _ltop is 0 0 0 0 + -- In the lsp spec from 3.16 Position takes a uinteger, + -- where uinteger is 0 - 2^31 - 1. lsp-types currently has the type of line + -- as Int. So instead of using `maxBound :: Int` we hardcode the maxBound of + -- uinteger. 2 ^ 31 - 1 == 2147483647 + -- Check this issue for tracking https://github.com/haskell/lsp/issues/354 + -- the change in lsp-types. } _ -> Nothing importSymbols = maybe [] pure $ diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index 800027c569..99c0b7c7a2 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -1729,7 +1729,7 @@ suggestImportTests = testGroup "suggest import actions" -- there isn't a good way to wait until the whole project is checked atm when waitForCheckProject $ liftIO $ sleep 0.5 let defLine = length imps + 1 - range = Range (Position defLine 0) (Position defLine maxBound) + range = Range (Position defLine 0) (Position defLine maxBoundUinteger) actions <- getCodeActions doc range if wanted then do @@ -2467,7 +2467,7 @@ fillTypedHoleTests = let let expectedCode = sourceCode newA newB newC doc <- createDoc "Testing.hs" "haskell" originalCode _ <- waitForDiagnostics - actionsOrCommands <- getCodeActions doc (Range (Position 9 0) (Position 9 maxBound)) + actionsOrCommands <- getCodeActions doc (Range (Position 9 0) (Position 9 maxBoundUinteger)) chosenAction <- liftIO $ pickActionWithTitle actionTitle actionsOrCommands executeCodeAction chosenAction modifiedCode <- documentContents doc @@ -2508,7 +2508,7 @@ fillTypedHoleTests = let , "ioToSome = " <> x ] doc <- createDoc "Test.hs" "haskell" $ mkDoc "_toException" _ <- waitForDiagnostics - actions <- getCodeActions doc (Range (Position 3 0) (Position 3 maxBound)) + actions <- getCodeActions doc (Range (Position 3 0) (Position 3 maxBoundUinteger)) chosen <- liftIO $ pickActionWithTitle "replace _toException with E.toException" actions executeCodeAction chosen modifiedCode <- documentContents doc @@ -3003,7 +3003,7 @@ addSigActionTests = let let expectedCode = after' def sig doc <- createDoc "Sigs.hs" "haskell" originalCode _ <- waitForDiagnostics - actionsOrCommands <- getCodeActions doc (Range (Position 5 1) (Position 5 maxBound)) + actionsOrCommands <- getCodeActions doc (Range (Position 5 1) (Position 5 maxBoundUinteger)) chosenAction <- liftIO $ pickActionWithTitle ("add signature: " <> sig) actionsOrCommands executeCodeAction chosenAction modifiedCode <- documentContents doc @@ -4800,7 +4800,7 @@ outlineTests = testGroup SkFile Nothing Nothing - (R 0 0 maxBound 0) + (R 0 0 maxBoundUinteger 0) loc (Just $ List cc) classSymbol name loc cc = DocumentSymbol name @@ -5991,3 +5991,8 @@ listOfChar | ghcVersion >= GHC90 = "String" thDollarIdx :: Int thDollarIdx | ghcVersion >= GHC90 = 1 | otherwise = 0 + +-- | We don't have a uinteger type yet. So hardcode the maxBound of uinteger, 2 ^ 31 - 1 +-- as a constant. +maxBoundUinteger :: Int +maxBoundUinteger = 2147483647 \ No newline at end of file