From 2c70722baa943a0050017b46fe46a64abfa5353b Mon Sep 17 00:00:00 2001 From: Chet Husk Date: Sat, 14 Oct 2023 16:59:07 -0500 Subject: [PATCH] Fix bug in inlay hints for members/constructors This bug resulted in member/constructor hints sometimes being applied just before the leftmost open paren. --- src/FsAutoComplete.Core/InlayHints.fs | 2 +- test/FsAutoComplete.Tests.Lsp/InlayHintTests.fs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/FsAutoComplete.Core/InlayHints.fs b/src/FsAutoComplete.Core/InlayHints.fs index 584dd5421..a803caac6 100644 --- a/src/FsAutoComplete.Core/InlayHints.fs +++ b/src/FsAutoComplete.Core/InlayHints.fs @@ -107,7 +107,7 @@ let private getFirstPositionAfterParen (str: string) startPos = match str with | null -> -1 | str when startPos > str.Length -> -1 - | str -> str.IndexOf('(') + 1 + | str -> str.IndexOf('(', startPos) + 1 let private maxHintLength = 30 diff --git a/test/FsAutoComplete.Tests.Lsp/InlayHintTests.fs b/test/FsAutoComplete.Tests.Lsp/InlayHintTests.fs index a0467c6ca..b415411c0 100644 --- a/test/FsAutoComplete.Tests.Lsp/InlayHintTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/InlayHintTests.fs @@ -1049,9 +1049,9 @@ let private paramHintTests state = server """ type Parser(jsonText: string) = member _.Parse(decoder: string -> string) = decoder jsonText - $|let parse (decoder: string -> string) (str: string) = Parser$0(str).Parse(decoder)$| + $|let parse (decoder: string -> string) (str: string) = Parser($0str).Parse($0decoder)$| """ - [ paramHint "jsonText" ] + [ paramHint "jsonText"; paramHint "decoder" ] testList "operator"