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

Commit

Permalink
Fixes after first review
Browse files Browse the repository at this point in the history
  • Loading branch information
WebsiteDeveloper committed Apr 13, 2013
1 parent a079da6 commit b507ad0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
8 changes: 2 additions & 6 deletions src/language/HTMLUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,16 +402,12 @@ define(function (require, exports, module) {

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

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

// Make sure the cursor is not after an equal sign or a quote before we report the context as a tag.
Expand Down
20 changes: 10 additions & 10 deletions test/spec/CodeHintUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ define(function (require, exports, module) {
expect(tag).toEqual(HTMLUtils.createTagInfo(HTMLUtils.TAG_NAME));
});

it("should hint tagname for a closing tag", function () {
var pos = {"ch": 0, "line": 0};
setContentAndUpdatePos(pos,
["<html>", "<body>", "<div id='test' class='foo'></div>"],
"</body></ht", "ml>");

var tag = HTMLUtils.getTagInfo(myEditor, pos);
expect(tag).toEqual(HTMLUtils.createTagInfo(HTMLUtils.CLOSING_TAG, 6, "html"));
});

it("should find the tagname of the current tag if two tags are right next to each other", function () {
var pos = {"ch": 0, "line": 0};
setContentAndUpdatePos(pos,
Expand Down Expand Up @@ -237,16 +247,6 @@ define(function (require, exports, module) {
expect(tag).toEqual(HTMLUtils.createTagInfo());
});

it("should not hint anything inside a closing tag", function () {
var pos = {"ch": 0, "line": 0};
setContentAndUpdatePos(pos,
["<html>", "<body>", "<div id='test' class='foo'></div>"],
"</body></ht", "ml>");

var tag = HTMLUtils.getTagInfo(myEditor, pos);
expect(tag).toEqual(HTMLUtils.createTagInfo());
});

it("should not find attributes in an empty editor", function () {
var pos = {"ch": 0, "line": 0};
var attrs = HTMLUtils.getTagAttributes(myEditor, pos);
Expand Down

0 comments on commit b507ad0

Please sign in to comment.