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 off by one in code lens resolve #994

Conversation

baronfel
Copy link
Contributor

Fixes ionide/ionide-vscode-fsharp#1763

Turns out it was an off by one! We basically should never use Pos.mkPos directly IMO if possible :(

@@ -1776,70 +1776,67 @@ type FSharpLspServer(state: State, lspClient: FSharpLspClient) =

let handler f (arg: CodeLens) =
async {
let pos = FcsPos.mkPos (arg.Range.Start.Line + 1) (arg.Range.Start.Character + 2)
let pos = protocolPosToPos arg.Range.Start
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the core fix, the rest is refactoring

@baronfel baronfel force-pushed the support-reference-lens-for-1-char-identifiers branch from f54da69 to a675d94 Compare August 17, 2022 14:43
@Krzysztof-Cieslak
Copy link
Member

CI failing with errors that look related to code lenses...

@baronfel
Copy link
Contributor Author

yeah, the type signature lenses in particular. I'll get it green at some point.

@@ -481,7 +481,7 @@ type ParseAndCheckResults
Ok(symboluse, symboluses)

member __.TryGetSignatureData (pos: Position) (lineStr: LineStr) =
match Lexer.findLongIdents (pos.Column - 1, lineStr) with
match Lexer.findLongIdents (pos.Column, lineStr) with
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing the first off-by-one (https://github.com/fsharp/FsAutoComplete/pull/994/files#r948031768) surfaced this off-by-one.

sigh

@@ -101,10 +101,23 @@ let tests state =
(args[1] :?> JObject).ToObject<Ionide.LanguageServerProtocol.Types.Position>(),
(args[2] :?> JArray) |> Seq.map (fun t -> (t:?>JObject).ToObject<Ionide.LanguageServerProtocol.Types.Location>()) |> Array.ofSeq
Expect.equal filePath doc.Uri "File path should be the doc we're checking"
Expect.equal triggerPos { Line = 1; Character = 8 } "Position should be 0:0"
Expect.equal triggerPos { Line = 1; Character = 6 } "Position should be 1:6"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changed because we stopped adding 2 to the column count as part of this fix. Why did we do that originally? Completely unknown to me reasons.

@Krzysztof-Cieslak Krzysztof-Cieslak merged commit 71f4dc4 into ionide:main Aug 17, 2022
@baronfel baronfel deleted the support-reference-lens-for-1-char-identifiers branch August 17, 2022 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reference codelense not shown if the function/variable is a single letter
2 participants