Repository: vscode
Issue: Color picker palette canvas has incorrect RGB calculation when paired with long hover information
Labels: bug,editor-color-picker

Type: <b>Bug</b>

The VSCode Color Picker is attached on top of any Hover information contributed by an extension / language server for the relevant token.

When this hover information is small, the ColorPicker size is computed as normal, and there are no issues with the colors provided by VSCode to the "provideColorPresentations" provider.

However, when the hover information is large (and also it needs be multiline it seems to reproduce the bug), the color picker width is increased, but the formula used to convert the graphical picker location to RGB is incorrect, leading to weird behaviour.

This is best seen via examples.

In the first video, we have a small hover information. The bounds of the color picker are computed correctly and the numbers are presented fine (here I return the exact same numbers passed as `vscode.Color` to the `providerColorPresentations` method).

https://github.com/microsoft/vscode/assets/19635171/1beac3e0-dd6b-451f-9e85-532b43ef16bf


On the other hand, when there is larger hover information, in this second video the bounds are computed incorrectly. This can be seen when the mouse moves out of the picker UI bounds, but the numbers are still changing - it is not clamped to the end of the UI like in the small example.

https://github.com/microsoft/vscode/assets/19635171/dab7ee1f-7ec9-4984-b2ee-8b33f48b45ac


I have pushed a minimal repro extension as an example at https://github.com/JohnnyMorganz/color-picker-bug. Launch the extension then create a plaintext file. `ShortColor.new(r, g, ,b)` has a small hover info, whilst `LongColor.new(r, g, b)` has a large hover info, causing the bug.

Original report: https://github.com/JohnnyMorganz/luau-lsp/issues/510

VS Code version: Code 1.85.1 (0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2, 2023-12-13T09:49:37.021Z)
OS version: Windows_NT x64 10.0.22621
Modes:

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz (12 x 2592)|
|GPU Status|2d_canvas: enabled<br>canvas_oop_rasterization: enabled_on<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>video_decode: enabled<br>video_encode: enabled<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled<br>webgpu: enabled|
|Load (avg)|undefined|
|Memory (System)|15.71GB (1.12GB free)|
|Process Argv|--crash-reporter-id 0ad0ddb1-cb07-4747-b87f-f1d8d6eb14bc|
|Screen Reader|no|
|VM|0%|
</details><details><summary>Extensions (43)</summary>

Extension|Author (truncated)|Version
---|---|---
tsl-problem-matcher|amo|0.6.2
vscode-tailwindcss|bra|0.10.4
doxdocgen|csc|1.4.0
vscode-eslint|dba|2.4.2
gitlens|eam|14.6.1
EditorConfig|Edi|0.16.4
prettier-vscode|esb|10.1.0
vscode-rojo|eva|2.1.2
wally-utilities|fil|0.4.5
vscode-github-actions|git|0.26.2
vscode-pull-request-github|Git|0.78.1
better-cpp-syntax|jef|1.17.2
luau-lsp|Joh|1.27.0
stylua|Joh|1.5.0
cmake-language-support-vscode|jos|0.0.9
Kotlin|mat|1.7.1
insta|mit|1.0.6
vscode-dotnet-runtime|ms-|2.0.0
black-formatter|ms-|2023.6.0
isort|ms-|2023.10.1
python|ms-|2023.22.1
vscode-pylance|ms-|2023.12.1
jupyter|ms-|2023.11.1003402403
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-containers|ms-|0.327.0
remote-ssh|ms-|0.107.1
remote-ssh-edit|ms-|0.86.0
remote-wsl|ms-|0.81.8
vscode-remote-extensionpack|ms-|0.25.0
cmake-tools|ms-|1.16.32
cpptools|ms-|1.18.5
cpptools-extension-pack|ms-|1.3.0
extension-test-runner|ms-|0.0.5
remote-explorer|ms-|0.4.1
remote-server|ms-|1.5.0
vsliveshare|ms-|1.0.5900
rust-analyzer|rus|0.3.1782
even-better-toml|tam|0.19.2
cmake|twx|0.0.17
vscode-lldb|vad|1.10.0

(1 theme extensions excluded)

</details><details>
<summary>A/B Experiments</summary>

```
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263:30899288
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
azure-dev_surveyonecf:30548226
f6dab269:30613381
showlangstatbar:30737416
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
dsvsc013:30795093
dsvsc014:30804076
dsvsc015:30845448
pythontestfixt:30902429
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:30885898
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
aa_t_chat:30882232
dsvsc019:30917259
cp7184t:30925682

```

</details>

<!-- generated by issue reporter -->