Commit 3b9a170
[Repo Assist] fix: show hover documentation for FSI hash directives (#r, #load, #nowarn, etc.) (#1504)
* fix: show hover documentation for FSI hash directives (#r, #load, #nowarn, 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>
* ci: trigger checks
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent b405c41 commit 3b9a170
4 files changed
Lines changed: 78 additions & 7 deletions
File tree
- src/FsAutoComplete.Core
- test/FsAutoComplete.Tests.Lsp
- TestCases/Tooltips
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
45 | 61 | | |
46 | 62 | | |
47 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
360 | | - | |
361 | | - | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
362 | 392 | | |
363 | 393 | | |
364 | 394 | | |
| |||
380 | 410 | | |
381 | 411 | | |
382 | 412 | | |
383 | | - | |
384 | | - | |
385 | | - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
386 | 427 | | |
387 | | - | |
| 428 | + | |
388 | 429 | | |
389 | 430 | | |
390 | 431 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | | - | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
628 | 639 | | |
629 | 640 | | |
630 | 641 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
0 commit comments