Skip to content

Commit

Permalink
Fix off-by-one
Browse files Browse the repository at this point in the history
  • Loading branch information
georgewfraser committed Sep 1, 2018
1 parent b0acc4e commit c3fa12b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/FSharpLanguageServer/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ type Server(client: ILanguageClient) =
let file = FileInfo(p.textDocument.uri.LocalPath)
let! c = checkOpenFile(file, true, false)
let line = lineContent(file, p.position.line)
let maybeId = QuickParse.GetCompleteIdentifierIsland false line (p.position.character - 1)
let maybeId = QuickParse.GetCompleteIdentifierIsland false line (p.position.character)
match c, maybeId with
| Error(errors), _ ->
dprintfn "Check failed, ignored %d errors" (List.length(errors))
Expand Down
14 changes: 14 additions & 0 deletions tests/FSharpLanguageServer.Tests/ServerTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,20 @@ let ``hover over function``() =
| None -> Assert.Fail("No hover")
| Some hover -> if List.isEmpty hover.contents then Assert.Fail("Hover list is empty")

[<Test>]
let ``hover over left edge``() =
let client, server = createServerAndReadFile("MainProject", "Hover.fs")
match server.Hover(textDocumentPosition("MainProject", "Hover.fs", 3, 13)) |> Async.RunSynchronously with
| None -> Assert.Fail("No hover")
| Some hover -> if List.isEmpty hover.contents then Assert.Fail("Hover list is empty")

[<Test>]
let ``hover over right edge``() =
let client, server = createServerAndReadFile("MainProject", "Hover.fs")
match server.Hover(textDocumentPosition("MainProject", "Hover.fs", 3, 17)) |> Async.RunSynchronously with
| None -> Assert.Fail("No hover")
| Some hover -> if List.isEmpty hover.contents then Assert.Fail("Hover list is empty")

[<Test>]
let ``hover over qualified name``() =
let client, server = createServerAndReadFile("MainProject", "Hover.fs")
Expand Down

0 comments on commit c3fa12b

Please sign in to comment.