Skip to content

Commit 3ec7a3f

Browse files
devvaannshabose
authored andcommitted
fix: rightly place cursor when color values are used from hints
1 parent a402fb1 commit 3ec7a3f

File tree

1 file changed

+14
-7
lines changed
  • src/extensions/default/CSSCodeHints

1 file changed

+14
-7
lines changed

src/extensions/default/CSSCodeHints/main.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,8 @@ define(function (require, exports, module) {
582582
* Checks whether the expandedAbbr has any number.
583583
* For instance: `m0` expands to `margin: 0;`, so we need to display the whole thing in the code hint
584584
* Here, we also make sure that abbreviations which has `#`, `,` should not be included, because
585-
* `color` expands to `color: #000;` or `color: rgb(0, 0, 0)`. So this actually has numbers, but we don't want to display this.
585+
* `color` expands to `color: #000;` or `color: rgb(0, 0, 0)`.
586+
* So this actually has numbers, but we don't want to display this.
586587
*
587588
* @param {String} expandedAbbr the expanded abbr returned by EXPAND_ABBR emmet api
588589
* @returns {boolean} true if expandedAbbr has numbers (and doesn't include '#') otherwise false.
@@ -738,12 +739,18 @@ define(function (require, exports, module) {
738739

739740
var parenMatch = hint.match(/\(.*?\)/);
740741
if (parenMatch) {
741-
// value has (...), so place cursor inside opening paren
742-
// and keep hints open
743-
adjustCursor = true;
744-
newCursor = { line: cursor.line,
745-
ch: start.ch + parenMatch.index + 1 };
746-
keepHints = true;
742+
// Only adjust cursor for non-color values
743+
if (!hint.startsWith('rgb') &&
744+
!hint.startsWith('rgba') &&
745+
!hint.startsWith('hsl') &&
746+
!hint.startsWith('hsla')) {
747+
// value has (...), so place cursor inside opening paren
748+
// and keep hints open
749+
adjustCursor = true;
750+
newCursor = { line: cursor.line,
751+
ch: start.ch + parenMatch.index + 1 };
752+
keepHints = true;
753+
}
747754
}
748755
}
749756

0 commit comments

Comments
 (0)