From f0629b4e6a9a27f108d4118390421ee8237a9e18 Mon Sep 17 00:00:00 2001 From: Pluto Date: Sat, 17 Jan 2026 12:53:16 +0530 Subject: [PATCH] fix: emmet not working for abbreviations when written inside a tag --- src/extensions/default/HTMLCodeHints/main.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/extensions/default/HTMLCodeHints/main.js b/src/extensions/default/HTMLCodeHints/main.js index fcf8ea4f9..b7ca92503 100644 --- a/src/extensions/default/HTMLCodeHints/main.js +++ b/src/extensions/default/HTMLCodeHints/main.js @@ -214,6 +214,7 @@ define(function (require, exports, module) { function _findAbbreviationStart(line, cursorCh) { let start = cursorCh; let insideBraces = false; + let lastGtPos = -1; // If the cursor is right before a closing brace, adjust it to be "inside" the braces if (line.charAt(start) === '}' || line.charAt(start) === ']') { @@ -232,6 +233,20 @@ define(function (require, exports, module) { insideBraces = false; } + // if we hit '<', this means that we've entered an HTML tag (e.g.,

,

) + // so in that case we need to return position right after the last '>' (we store it in lastGtPos) + // use case scenario: "

lorem" to extract "lorem" instead of "

lorem" + if (char === '<') { + if (lastGtPos !== -1) { + return lastGtPos + 1; + } + break; + } + + if (char === '>') { + lastGtPos = start - 1; + } + // If the character is valid as part of an Emmet abbreviation, continue scanning backwards if (_isEmmetChar(char, insideBraces)) { start--;