Skip to content

[Repo Assist] fix: improve delegate type tooltips using FSharpDelegateSignature API#1485

Merged
Krzysztof-Cieslak merged 4 commits intomainfrom
repo-assist/fix-issue-627-delegate-tooltips-af465ee40486270d
Feb 26, 2026
Merged

[Repo Assist] fix: improve delegate type tooltips using FSharpDelegateSignature API#1485
Krzysztof-Cieslak merged 4 commits intomainfrom
repo-assist/fix-issue-627-delegate-tooltips-af465ee40486270d

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated pull request from Repo Assist.

Fixes #627Tooltips for delegates are terrible

Root Cause

The delegateTip function in both SignatureFormatter.fs and DocumentationFormatter.fs was calling getFuncSignatureWithIdent on the delegate's Invoke method with ident=6. This function is designed for member signatures with alignment padding, producing awkward multi-line output for delegates.

For no-argument delegates (e.g. System.Action), the result was especially broken: the [ [] ] branch with isDelegate=true returned just "unit" with no indentation, giving:

type Action =
   delegate of
unit
```

For delegates with parameters, the output had excessive indentation and the `->` return arrow on its own indented line:

```
type MyDelegate =
   delegate of
      arg: string
         -> int
```

## Fix

Replace the `Invoke`-method approach with direct use of `FSharpEntity.FSharpDelegateSignature`, which provides:
- `DelegateArguments`: list of `(string option * FSharpType)` — optional parameter name + type
- `DelegateReturnType`: the return type

This produces a clean, single-line format consistent with F# delegate syntax:

```
type MyDelegate =
   delegate of arg: string -> int

type Action =
   delegate of unit -> unit

type Func<'T1,'T2,'TResult> =
   delegate of arg1: 'T1 * arg2: 'T2 -> 'TResult

Changes

  • src/FsAutoComplete.Core/SignatureFormatter.fs — updated delegateTip
  • src/FsAutoComplete.Core/DocumentationFormatter.fs — updated delegateTip

Test Status

src/FsAutoComplete.Core builds successfully (dotnet build -f net8.0)
src/FsAutoComplete (main LSP server) builds successfully
✅ Code formatted with dotnet fantomas (no changes needed)

Note: The full solution build has a pre-existing failure in test/FsAutoComplete.DependencyManager.Dummy targeting netstandard2.0 only, unrelated to these changes.

Generated by Repo Assist for issue #627

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@afb00b92a9514fee9a14c583f059a03d05738f70

Closes #627

The previous implementation used getFuncSignatureWithIdent on the
delegate's Invoke method, which produced badly formatted multi-line
output with excess indentation. For no-argument delegates the output
was especially broken (just 'unit' with no indentation).

Replace with direct use of FSharpEntity.FSharpDelegateSignature, which
provides the delegate arguments (with optional names) and return type.
This produces a clean single-line format:

  type MyDelegate =
     delegate of arg: string -> int

instead of:

  type MyDelegate =
     delegate of
        arg: string
           -> int

For zero-argument delegates, 'unit' is shown as the argument type,
consistent with F# delegate syntax.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Krzysztof-Cieslak
Copy link
Member

/repo-assist add tests to it, including e2e hover test

Add e2e hover tests (verifySignature) that verify the delegate type
signature formatter produces clean output:
- NoArgDelegate (unit -> unit)
- SingleArgDelegate (named arg -> int)
- MultiArgDelegate (two named args -> bool)
- UnannotatedDelegate (unnamed arg -> int)

Also add a DocumentationFormatter test via the FSharpDocumentation
endpoint (InfoPanelTests) to cover the parallel change in
DocumentationFormatter.fs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor Author

Commit pushed: 718b701

Generated by Repo Assist

@github-actions
Copy link
Contributor Author

🤖 This is an automated response from Repo Assist.

Done! I've added tests for the delegate tooltip fix. Here's what was added:

E2E Hover Tests (SignatureFormatter path)

Added 4 verifySignature test cases to the tooltipTests function in CoreTests.fs, using new delegate type declarations in TestCases/Tooltips/Script.fsx:

Type Expected hover signature
type NoArgDelegate = delegate of unit -> unit type NoArgDelegate =
delegate of unit -> unit
type SingleArgDelegate = delegate of arg: string -> int type SingleArgDelegate =
delegate of arg: string -> int
type MultiArgDelegate = delegate of a: string * b: int -> bool type MultiArgDelegate =
delegate of a: string * b: int -> bool
type UnannotatedDelegate = delegate of string -> int type UnannotatedDelegate =
delegate of string -> int

These exercise the verifySignature hover assertion, which tests SignatureFormatter.delegateTip.

DocumentationFormatter Test

Added one test case to InfoPanelTests.fs using server.FSharpDocumentation (the info panel endpoint) with a delegate type in TestCases/FormattedDocumentation/Script.fsx. This covers the parallel change in DocumentationFormatter.delegateTip.

Build status

✅ Build succeeded (dotnet build -f net8.0) with 0 warnings and 0 errors after fantomas formatting.

The LSP integration tests require full server startup (~5–10 min) and cannot run inline in this environment, so test execution was not completed here — CI will validate them.

Generated by Repo Assist for issue #1485

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@afb00b92a9514fee9a14c583f059a03d05738f70

@Krzysztof-Cieslak Krzysztof-Cieslak marked this pull request as ready for review February 26, 2026 22:13
@Krzysztof-Cieslak Krzysztof-Cieslak enabled auto-merge (squash) February 26, 2026 22:14
@Krzysztof-Cieslak Krzysztof-Cieslak merged commit f285889 into main Feb 26, 2026
18 of 19 checks passed
github-actions bot added a commit that referenced this pull request Feb 27, 2026
…ip fix) to v0.84.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tooltips for delegates are terrible

1 participant