Skip to content

[Repo Assist] fix: show hover documentation for FSI hash directives (#r, #load, #nowarn, etc.)#1504

Draft
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/fix-issue-1225-hash-directive-hover-3973027e21256f79
Draft

[Repo Assist] fix: show hover documentation for FSI hash directives (#r, #load, #nowarn, etc.)#1504
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/fix-issue-1225-hash-directive-hover-3973027e21256f79

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated PR from Repo Assist.

Closes #1225

Root Cause

Hovering over a hash directive like #r, #load, #nowarn returned None (no tooltip shown) for two reasons:

  1. Lexer.findLongIdents returns None for multi-character directives like #nowarn — the F# tokenizer emits them as directive tokens, not plain identifier tokens.
  2. Even for short directives like #r where an identifier IS found, there was no lookup against the hash-directive description table.

Both code paths fell through to None even though KeywordList.hashDirectives already contained the descriptions needed for completion:

let hashDirectives =
  [ "r", "References an assembly or a nuget: package"
    "nowarn", "Disables a compiler warning or warnings"
    // ...
  ]
```

## Fix

### `KeywordList.fs`

Added `hashDirectiveTooltips`: a dictionary mapping each hash directive key to a synthetic `ToolTipText` built from the existing `hashDirectives` descriptions (same source used for completion item documentation).

### `ParseAndCheckResults.fs` — `TryGetToolTipEnhanced`

Two additions:

1. **In the `findLongIdents = None` branch**: when `findLongIdents` returns `None`, check whether the line starts with `#` and the cursor column is within the directive keyword extent. If so, return the tooltip from `hashDirectiveTooltips`. This handles multi-character directives like `#nowarn`, `#load`, `#light`.

2. **In the `keywordTooltips` fallback**: when `findLongIdents` does find a short identifier but it's not in `keywordTooltips`, check whether the current line starts with `#(ident)`. This handles short directives like `#r` and `#I`.

## Test Status

New test: `verifyDescription 123u 3u`  hover at column 3 of `#nowarn "40"` on the test script returns the expected `"Disables a compiler warning or warnings"` description.

```
Passed: 88 | Failed: 4 | Skipped: 0 | Total: 92

The 4 failures are pre-existing: active pattern ... option(objnull * ...) vs option(obj * ...) — a difference in FCS nullable-annotation rendering unrelated to this change (present on main before this PR).

Generated by Repo Assist ·

To install this agentic workflow, run

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

…warn, etc.)

Resolves #1225

## Root Cause

Hovering over a hash directive like `#r`, `#load`, `#nowarn` returned `None`
for two reasons:
1. `Lexer.findLongIdents` returns `None` for multi-character directives like
   `#nowarn` because the F# tokenizer emits them as directive tokens, not plain
   identifier tokens.
2. Even for short directives like `#r` where an identifier IS found, there was
   no lookup in the hash-directive description table.

## Fix

- Added `hashDirectiveTooltips` to `KeywordList.fs`: a dictionary mapping each
  hash directive key (e.g. `"nowarn"`) to a synthetic `ToolTipText` built from
  the existing `hashDirectives` descriptions already used for completion.
- In `TryGetToolTipEnhanced` (`ParseAndCheckResults.fs`): when
  `findLongIdents` returns `None`, check whether the line starts with a `#`
  and the cursor is within the directive keyword; if so, return the tooltip from
  `hashDirectiveTooltips`.
- Also added a fallback in the `| _ ->` branch (when `findLongIdents` finds an
  ident but it is not a keyword) to handle short directives like `#r` and `#I`.

## Test

Added `#nowarn "40"` to the tooltip test script and a `verifyDescription`
assertion that hovering on column 3 of that line returns the expected
`"Disables a compiler warning or warnings"` description.

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.

F# interactive directives not showing docs once written down, also true for #nowarn, coloring is not conistent (purple?)

0 participants