posit-dev / positron

Positron, a next-generation data science IDE
Other
2.46k stars 73 forks source link

Color preview doesn't render if the file or Jupyter cell starts with the color code #4809

Open apcamargo opened 2 hours ago

apcamargo commented 2 hours ago

Positron and OS details:

Positron Version: 2024.09.0 (Universal) build 77
Code - OSS Version: 1.93.0
Commit: 9b6f7c066546a4c7f104368fc769fb3768b08bfd
Date: 2024-09-23T02:43:50.589Z
Electron: 30.4.0
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Darwin x64 24.0.0

Remote session in:

$ cat /etc/os-release

PRETTY_NAME="Ubuntu 24.04 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo

Interpreter details:

Interpreter-independent.

Describe the issue:

The color preview doesn't render if the file or Jupyter cell starts with the color representation (hexadecimal or rgb()).

Steps to reproduce the issue:

Write a color code at the beginning of a file or Jupyter cell:

image

If I add a space before the #, the preview will render. Apparently this only happens when the first line starts with the color.

This happens for the rgb() notation as well (see below). Other color representations (oklch(), hsl(), etc.) don't render at all, but this is likely a separate issue.

image

Expected or desired behavior:

Colors should be presented in a consistent manner and not depend on their position in the file.

jmcphers commented 1 hour ago

This behavior comes from the upstream project, VS Code. Here's a screenshot from VS Code:

image

Note that (unlike Positron) VS Code does not always show color decorators by default; you need to turn it by checking "Color Decorators" (to enable the feature) and "Default Color Decorators" (to show them in all file types).

image

It wouldn't be impossible to fix it in Positron by patching the behavior, but we'd encourage you to report it upstream. https://github.com/microsoft/vscode/issues