microsoft / vscode

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

Shortcut for opening color picker and insert color of selected format #52364

Closed probablykasper closed 1 year ago

probablykasper commented 6 years ago

Problem

A huge dealbreaker for me is that VSCode just doesn't let me use the color picker ever, because I'm using Sass files. There does not seem to be any color picker extension that provides the functionality either, that isn't Windows-specific (I'm running macOS).

Feature request

I'd like the ability to spawn a color picker anywhere. So there would be a command that does exactly that, and when you're done it inserts the color code.

A nice inclusion would be if it could know if the cursor is in a color code, and accordingly update that color code. VSCode seems to do this only in a few file types now, which is a bummer for anyone not using those. I don't demand this, as long as I can get a color picker I'm content.

vscodebot[bot] commented 6 years ago

(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

justablob commented 6 years ago

I'd love to see this feature aswell, +1.

octref commented 6 years ago

I'm closing this as Sass do not have a language server, which is needed to support this feature.

A simplified explanation as to how color picker works:

CSS/Less/Scss have language servers that can respond with color information properly. Sass doesn't have a LS to begin with.

probablykasper commented 6 years ago

@octref That was not the main thing this is about. I want to spawn a color picker anywhere (using a shortcut), regardless of whether there's already a color code in the document or not.

octref commented 6 years ago

@SpectralKH If you mean you want to spawn a color picker that doesn't have anything to do with the color code in a document, you can implement it as a Webview extension or look for existing extensions: https://marketplace.visualstudio.com/search?term=color%20picker&target=VSCode&category=All%20categories&sortBy=Relevance

probablykasper commented 6 years ago

@octref None of the existing ones work for me (on macOS). This should be built-in and consistent between platforms.

octref commented 6 years ago

If you mean you want this kind of color picker, but for Sass, see my response about Language Server above:

image

We have this component built-in, but we do not have resource to add support for each language so it shows this color picker component.

probablykasper commented 6 years ago

@octref I want that color picker brought up by a shortcut anywhere.

octref commented 6 years ago

You bring it up with a shortcut and pick a color, what do you expect to happen then?

probablykasper commented 6 years ago

@octref I expect the popup from the image you shared to show up. Then I'd pick a color and press enter or something for the color code to be pasted in.

To change the type of color code type (HEX, RGB, etc) to paste in, you could

octref commented 6 years ago

For that I suggest you use an alternative tool, like Sip app https://sipapp.io. But anyway, I'll keep it open and I've updated the title.

chhh commented 6 years ago

I'm looking for the same functionality - just spawn a color-picker with a command and insert the hex/rgb value at the caret no matter what file type is open.

The vs marketpalce has two extensions with colorpickers. One doesn't work at all, the other uses ugly legacy windows color picker which is not very user-friendly.

Considering this color picker is already there...

cburkins commented 5 years ago

In the same boat, trying to get the color picker to activate while in a JSX file.

DavidHanover commented 5 years ago

I am trying to specify colors within strings inside a javascript object. Would LOVE to have color picker available to change on the fly instead of going to browser, finding hex codes from designer app, copying, going back to vscode, carefully selecting the right hex code, pasting in, making sure not have duplicate # characters, making sure the string isn't ruined by whitespace or missing " character, etc.

vrgimael commented 5 years ago

Same problem using JSX... Isn't there any command to force launch the picker on whatever file extension and then just paste the result in the text?

borisBelloc commented 5 years ago

looking for a color picker in JS / React native files...

planetrocky commented 5 years ago

I really would like a color picker to open in any source file type!

jqweryjson commented 5 years ago

same problem in any js file)

allanwhite commented 5 years ago

Just wanted to add my voice to the chorus of developers: the VS Code color picker (which is nice!) should be invokable with a keyboard shortcut, from any filetype.

The UX decision to make it appear on hover, of course, only works on certain filetypes. It's probably not simple to add every filetype to detect color objects. This decision traded elegance for a fairly big limitation (and didn't take into account how devs work with color strings, which seems to be all over the place).

Sunjammer commented 5 years ago

Same here. It's such a generally useful thing these days, especially with the amount of inline styles in jsx/tsx.

ransagy commented 5 years ago

I really am surprised this doesn't exist, in VSCode or in extensions. I was trying to edit a JSON file that contained hex color definitions in it (a configuration file for something) and there's just no way to get a decent editing experience in that case. One extension shows/renders the colors, so that's half the story, but no easy way to pick/edit.

adamwatters commented 5 years ago

I ran into this problem myself, so I built a color picker extension that can be opened anywhere and works without any dependencies. Here's a link, or just search 'vscode-color-pick'. Very basic so far, but I've already found it useful while writing JSX. I'd love feedback about what features could be added to make it more useful.

adamwatters commented 5 years ago

My aforementioned extension Color Pick now supports rgba(). Go try it!

mwittmann commented 5 years ago

Yes, please add the ability to assign a keyboard shortcut to opening the native color picker. Why? (a) Even when a color preview square is showing, sometimes the "hover" behavior to show the picker is finicky and unreliable (need to mouse out and over multiple times to get it to show). (b) For files for which VSCode does not recognize colors. For example, I have a PHP file with an HTML