дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
Both .icls readers (the theme converter and Settings > Color Scheme > Import) accepted only bare hex, so schemes like One Dark that write #rrggbb lost most colours. One iclsColor helper now follows IntelliJ's rules (bare, # or 0x prefixes); the settings import still leaves out RRGGBBAA values. Co-authored-by: Rhombicdodecahedron <[email protected]>
13 рядки
638 B
TypeScript
13 рядки
638 B
TypeScript
/**
|
|
* An `.icls` colour value as IntelliJ reads it (`ValueElementReader.toColor`): six or eight hex digits
|
|
* (`RRGGBB`, `RRGGBBAA`), with or without a leading `#` or `0x`, else a hex number with its leading zeros
|
|
* dropped (`"0"` is black, `"ff"` is `#0000ff`). Returns lower-case `#rrggbb` / `#rrggbbaa`.
|
|
*/
|
|
export function iclsColor(value: string | null | undefined): string | undefined {
|
|
const v = value?.trim().toLowerCase();
|
|
if (!v) return undefined;
|
|
const full = /^(?:#|0x)?([0-9a-f]{6}|[0-9a-f]{8})$/.exec(v);
|
|
if (full) return `#${full[1]}`;
|
|
return /^[0-9a-f]{1,5}$/.test(v) ? `#${v.padStart(6, "0")}` : undefined;
|
|
}
|