Skip to content

Commit

Permalink
Fix signatureHelp IndexOutOfRangeException issue (#1040) (#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
vain0x authored Mar 3, 2023
1 parent ce0dc48 commit 8ec18cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/FsAutoComplete.Core/FileSystem.fs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,12 @@ type NamedText(fileName: string<LocalPath>, 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.
Expand Down
6 changes: 5 additions & 1 deletion test/FsAutoComplete.Tests.Lsp/SignatureHelpTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down

0 comments on commit 8ec18cc

Please sign in to comment.