Skip to content

feat: suggest previously used colors in file#2143

Merged
abose merged 4 commits intophcode-dev:mainfrom
devvaannsh:color
Feb 24, 2025
Merged

feat: suggest previously used colors in file#2143
abose merged 4 commits intophcode-dev:mainfrom
devvaannsh:color

Conversation

@devvaannsh
Copy link
Member

Previously used colors within a file will be prioritized in the color hint suggestions. These colors will be sorted in descending order based on their frequency of occurrence, ensuring that the most frequently used color appears at the top. This prioritization happens before displaying any other color hints.

Works for all color types. (hex, rgb, named colors)

Screenshot 2025-01-30 122837

@devvaannsh
Copy link
Member Author

devvaannsh commented Feb 23, 2025

The live server tests were failing due to two major reasons:

  1. In an HTML file with the following content:
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Simple Test</title>
    <link rel="stylesheet" href="simpleShared.css">
    <link rel="stylesheet" href="simple1.css">
    <style>
        #testId2 {
            color: red;
        }
    </style>
</head>
<body class="testClass">
    <p id="testId" class="testClass">Brackets is awesome!</p>
    <p id="testId2" class="testClass2">Red is bad. Green is good.</p>
</body>
</html>

Here, Red inside the <p> tag should not be suggested as a valid color, but it was still showing up in the code hints. This was causing the live server tests to break.

  1. In a CSS file:
.testClass {
    color: #000;
}

Earlier, the tests expected colors that start with a (like aliceblue, antiquewhite) to appear at the top. But after the color feature update, #000 was showing up before other hints, which was also breaking the tests.

@sonarqubecloud
Copy link

@abose abose merged commit c99593f into phcode-dev:main Feb 24, 2025
17 of 18 checks passed
@abose
Copy link
Member

abose commented Feb 24, 2025

LGTM . Merging.
Thanks for the feature @devvaannsh

@devvaannsh devvaannsh deleted the color branch February 24, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants