diff --git a/src/FsAutoComplete.Core/FileSystem.fs b/src/FsAutoComplete.Core/FileSystem.fs index 0159ed758..5f4f48690 100644 --- a/src/FsAutoComplete.Core/FileSystem.fs +++ b/src/FsAutoComplete.Core/FileSystem.fs @@ -245,7 +245,12 @@ type NamedText(fileName: string, str: string) = member x.TryGetPrevChar(pos: FSharp.Compiler.Text.Position) : (FSharp.Compiler.Text.Position * char) option = option { let! np = x.PrevPos pos - return np, x.GetCharUnsafe np + let! prevLineLength = x.GetLineLength(np) + + if np.Column < 1 || prevLineLength < np.Column then + return! x.TryGetPrevChar(np) + else + return np, x.GetCharUnsafe np } /// split the TotalRange of this document at the range specified. diff --git a/test/FsAutoComplete.Tests.Lsp/SignatureHelpTests.fs b/test/FsAutoComplete.Tests.Lsp/SignatureHelpTests.fs index 2a51c01ad..8f54bd1f1 100644 --- a/test/FsAutoComplete.Tests.Lsp/SignatureHelpTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/SignatureHelpTests.fs @@ -199,7 +199,11 @@ let issuesTests server = Expect.equal sigText "val count: x: int -> int" - "Should have no backticks because signatures are only ever rendered in `code` form") ] + "Should have no backticks because signatures are only ever rendered in `code` form") + testCaseAsync "issue #1040" // IndexOutOfRangeException + <| testSignatureHelp server "().ToString(\n\n,$0\n)" Manual (fun sigs -> + Expect.isSome sigs "Should have sigs" + ) ] let tests state = serverTestList "signature help" state defaultConfigDto None (fun server ->