Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit b507ad0

Browse files
Fixes after first review
1 parent a079da6 commit b507ad0

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

src/language/HTMLUtils.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -402,16 +402,12 @@ define(function (require, exports, module) {
402402

403403
// Check to see if this is the closing of a tag (either the start or end) self closing tag
404404
if (ctx.token.string === ">" || ctx.token.string === "/>") {
405-
return createTagInfo(CLOSING_TAG, offset);
405+
return createTagInfo();
406406
}
407407

408408
// Check to see if this is the closing of a tag (either the start or end) closing tag
409409
if (ctx.token.string.charAt(0) === "<" && ctx.token.string.charAt(1) === "/") {
410-
if (ctx.token.string.indexOf(">") === -1) {
411-
return createTagInfo(CLOSING_TAG, offset, ctx.token.string.slice(2));
412-
} else {
413-
return createTagInfo(CLOSING_TAG, offset, ctx.token.string.slice(2, ctx.token.string.indexOf(">") + 1));
414-
}
410+
return createTagInfo(CLOSING_TAG, offset + 2, ctx.token.string.slice(2));
415411
}
416412

417413
// Make sure the cursor is not after an equal sign or a quote before we report the context as a tag.

test/spec/CodeHintUtils-test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ define(function (require, exports, module) {
186186
expect(tag).toEqual(HTMLUtils.createTagInfo(HTMLUtils.TAG_NAME));
187187
});
188188

189+
it("should hint tagname for a closing tag", function () {
190+
var pos = {"ch": 0, "line": 0};
191+
setContentAndUpdatePos(pos,
192+
["<html>", "<body>", "<div id='test' class='foo'></div>"],
193+
"</body></ht", "ml>");
194+
195+
var tag = HTMLUtils.getTagInfo(myEditor, pos);
196+
expect(tag).toEqual(HTMLUtils.createTagInfo(HTMLUtils.CLOSING_TAG, 6, "html"));
197+
});
198+
189199
it("should find the tagname of the current tag if two tags are right next to each other", function () {
190200
var pos = {"ch": 0, "line": 0};
191201
setContentAndUpdatePos(pos,
@@ -237,16 +247,6 @@ define(function (require, exports, module) {
237247
expect(tag).toEqual(HTMLUtils.createTagInfo());
238248
});
239249

240-
it("should not hint anything inside a closing tag", function () {
241-
var pos = {"ch": 0, "line": 0};
242-
setContentAndUpdatePos(pos,
243-
["<html>", "<body>", "<div id='test' class='foo'></div>"],
244-
"</body></ht", "ml>");
245-
246-
var tag = HTMLUtils.getTagInfo(myEditor, pos);
247-
expect(tag).toEqual(HTMLUtils.createTagInfo());
248-
});
249-
250250
it("should not find attributes in an empty editor", function () {
251251
var pos = {"ch": 0, "line": 0};
252252
var attrs = HTMLUtils.getTagAttributes(myEditor, pos);

0 commit comments

Comments
 (0)