microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.94k stars 28.77k forks source link

[UI] Editor hover window size is strange #192042

Open xiaohai-huang opened 1 year ago

xiaohai-huang commented 1 year ago

Type: Bug

  1. Create a C# file
  2. Create a class with a very long summary
  3. Hover the mouse over the class name
/// <summary>
/// Arthur raises his sword and leaps towards an enemy hero, dealing 16/20/24% magic damage to the enemy hero's maximum health and knocking them up for 0.5 seconds. 
/// At the same time, he summons a holy seal to cover the landing area. 
/// The holy seal deals 85/105/125 points of magic damage per second to enemies within range for 5 seconds.
/// </summary>
public class Test
{

}

Actucal Result

The text in the hover window does not wrap properly and cannot see the whole summary.

strange window size

Expected Result

The hover window should show all the text and wrap automatically like what it does in JavaScript file.

image

VS Code version: Code 1.81.1 (6c3e3dba23e8fadc360aed75ce363ba185c49794, 2023-08-09T22:22:42.175Z) OS version: Windows_NT x64 10.0.22621 Modes:

System Info |Item|Value| |---|---| |CPUs|12th Gen Intel(R) Core(TM) i5-12400F (12 x 2496)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|31.84GB (19.10GB free)| |Process Argv|--crash-reporter-id eb7006a0-bb84-41ea-b1d9-64b84e84514c| |Screen Reader|no| |VM|0%|
Extensions (28) Extension|Author (truncated)|Version ---|---|--- vscode-eslint|dba|2.4.2 es7-react-js-snippets|dsz|4.4.3 gitlens|eam|14.2.1 prettier-vscode|esb|10.1.0 vscode-github-actions|git|0.26.1 docomment|k--|1.0.0 git-graph|mhu|1.30.0 csdevkit|ms-|0.4.10 csharp|ms-|2.0.436 vscode-dotnet-runtime|ms-|1.7.2 vscodeintellicode-csharp|ms-|0.1.26 python|ms-|2023.14.0 vscode-pylance|ms-|2023.8.50 jupyter|ms-|2023.7.1002162226 jupyter-keymap|ms-|1.1.2 jupyter-renderers|ms-|1.0.17 vscode-jupyter-cell-tags|ms-|0.1.8 vscode-jupyter-slideshow|ms-|0.1.5 remote-ssh-edit|ms-|0.86.0 remote-wsl|ms-|0.81.0 explorer-exclude|Pet|1.3.2 phind|phi|0.4.4 material-icon-theme|PKi|4.30.1 vscode-xml|red|0.26.1 LiveServer|rit|5.7.9 vs-code-prettier-eslint|rve|5.1.0 code-spell-checker|str|2.20.5 vstuc|vis|0.9.0
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstes627:30244334 vslsvsres303:30308271 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscoreces:30445986 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 pythonvs932:30410667 vscaat:30438848 vsclangdf:30486550 c4g48928:30535728 dsvsc012:30540252 pynewext54:30695312 azure-dev_surveyone:30548225 vsccc:30803844 2e4cg342:30602488 f6dab269:30613381 showlangstatbar:30737416 0bi6i642:30823812 a2ce3375:30757347 pythonfmttext:30731395 fixshowwlkth:30771522 showindicator:30805244 pythongtdpath:30769146 i26e3531:30792625 pythonnosmt12:30797651 pythonidxptcf:30805731 pythonnoceb:30805159 synctok:30821570 dsvsc013:30795093 dsvsc014:30804076 diffeditorv2:30821572 dsvsc015cf:30823818 ```
xiaohai-huang commented 1 year ago

Below is the output of C# LSP Trace Logs

[Trace - 10:42:15 PM] Received notification 'window/logMessage'.
Params: {
    "type": 4,
    "message": "[LanguageServerHost][04:42:15.593][Start]textDocument/hover"
}

[Trace - 10:42:15 PM] Received response 'textDocument/hover - (38)' in 7ms.
Result: {
    "contents": {
        "kind": "markdown",
        "value": "```csharp\r\nvoid AbilityThreeAction.OnUpdate()\r\n```\r\n  \r\nArthur&nbsp;summons&nbsp;3&nbsp;shields&nbsp;that&nbsp;circle&nbsp;around&nbsp;him,&nbsp;enemies&nbsp;that&nbsp;are&nbsp;struck&nbsp;by&nbsp;the&nbsp;shield&nbsp;will&nbsp;receive&nbsp;145/163/181/199/217/235&nbsp;\\(\\+80%&nbsp;physical&nbsp;bonus\\)&nbsp;Physical&nbsp;Damage\\.&nbsp;Shields&nbsp;last&nbsp;for&nbsp;5&nbsp;seconds\\.  \r\n"
    },
    "range": {
        "start": {
            "line": 25,
            "character": 23
        },
        "end": {
            "line": 25,
            "character": 31
        }
    }
}

I try to create a hover using the markdown provided by the C# LSP Logs.

  vscode.languages.registerHoverProvider("csharp", {
    provideHover(document, position, token) {
      return new vscode.Hover(
        "```csharp\r\nvoid AbilityThreeAction.OnUpdate()\r\n```\r\n  \r\nArthur&nbsp;summons&nbsp;3&nbsp;shields&nbsp;that&nbsp;circle&nbsp;around&nbsp;him,&nbsp;enemies&nbsp;that&nbsp;are&nbsp;struck&nbsp;by&nbsp;the&nbsp;shield&nbsp;will&nbsp;receive&nbsp;145/163/181/199/217/235&nbsp;\\(\\+80%&nbsp;physical&nbsp;bonus\\)&nbsp;Physical&nbsp;Damage\\.&nbsp;Shields&nbsp;last&nbsp;for&nbsp;5&nbsp;seconds\\.  \r\n"
      );
    },
  });

screenshot of the above hover code