Skip to content

Commit 88fcc3f

Browse files
devvaannshabose
authored andcommitted
fix: rightly place cursor when color values are used from hints
1 parent 5249713 commit 88fcc3f

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
@@ -581,7 +581,8 @@ define(function (require, exports, module) {
581581
* Checks whether the expandedAbbr has any number.
582582
* For instance: `m0` expands to `margin: 0;`, so we need to display the whole thing in the code hint
583583
* Here, we also make sure that abbreviations which has `#`, `,` should not be included, because
584-
* `color` expands to `color: #000;` or `color: rgb(0, 0, 0)`. So this actually has numbers, but we don't want to display this.
584+
* `color` expands to `color: #000;` or `color: rgb(0, 0, 0)`.
585+
* So this actually has numbers, but we don't want to display this.
585586
*
586587
* @param {String} expandedAbbr the expanded abbr returned by EXPAND_ABBR emmet api
587588
* @returns {boolean} true if expandedAbbr has numbers (and doesn't include '#') otherwise false.
@@ -736,12 +737,18 @@ define(function (require, exports, module) {
736737

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

0 commit comments

Comments
 (0)