Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix signatureHelp IndexOutOfRangeException issue (#1040) #1067

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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