From f50e376120537cd101b1809514588bfcc0dd082d Mon Sep 17 00:00:00 2001 From: Bernhard Sirlinger Date: Tue, 16 Apr 2013 19:17:52 +0200 Subject: [PATCH] Fixes after second review --- src/language/HTMLUtils.js | 2 +- test/spec/CodeHintUtils-test.js | 4 ++-- .../InlineEditorProviders-test-files/test1.html | 2 +- test/spec/InlineEditorProviders-test.js | 14 +++++++++++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/language/HTMLUtils.js b/src/language/HTMLUtils.js index 7f167562dba..38478222694 100644 --- a/src/language/HTMLUtils.js +++ b/src/language/HTMLUtils.js @@ -407,7 +407,7 @@ define(function (require, exports, module) { // 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) === "/") { - return createTagInfo(CLOSING_TAG, offset + 2, ctx.token.string.slice(2)); + 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. diff --git a/test/spec/CodeHintUtils-test.js b/test/spec/CodeHintUtils-test.js index 02e33c8b2ac..34c92fb2ce0 100644 --- a/test/spec/CodeHintUtils-test.js +++ b/test/spec/CodeHintUtils-test.js @@ -186,14 +186,14 @@ define(function (require, exports, module) { expect(tag).toEqual(HTMLUtils.createTagInfo(HTMLUtils.TAG_NAME)); }); - it("should hint tagname for a closing tag", function () { + it("should not hint anything inside a closing tag", function () { var pos = {"ch": 0, "line": 0}; setContentAndUpdatePos(pos, ["", "", "
"], ""); var tag = HTMLUtils.getTagInfo(myEditor, pos); - expect(tag).toEqual(HTMLUtils.createTagInfo(HTMLUtils.CLOSING_TAG, 6, "html")); + expect(tag).toEqual(HTMLUtils.createTagInfo(HTMLUtils.CLOSING_TAG, 2, "html")); }); it("should find the tagname of the current tag if two tags are right next to each other", function () { diff --git a/test/spec/InlineEditorProviders-test-files/test1.html b/test/spec/InlineEditorProviders-test-files/test1.html index b5bc8734841..8035194a733 100644 --- a/test/spec/InlineEditorProviders-test-files/test1.html +++ b/test/spec/InlineEditorProviders-test-files/test1.html @@ -8,6 +8,6 @@ {{3}}
- + \ No newline at end of file diff --git a/test/spec/InlineEditorProviders-test.js b/test/spec/InlineEditorProviders-test.js index 18ba6110962..21a54d5fd87 100644 --- a/test/spec/InlineEditorProviders-test.js +++ b/test/spec/InlineEditorProviders-test.js @@ -252,7 +252,7 @@ define(function (require, exports, module) { }); - it("should open a type selector", function () { + it("should open a type selector on opening tag", function () { initInlineTest("test1.html", 0); runs(function () { @@ -263,6 +263,18 @@ define(function (require, exports, module) { expect(inlinePos).toEqual(this.infos["test1.css"].offsets[0]); }); }); + + it("should open a type selector on closing tag", function () { + initInlineTest("test1.html", 9); + + runs(function () { + var inlineWidget = EditorManager.getCurrentFullEditor().getInlineWidgets()[0]; + var inlinePos = inlineWidget.editors[0].getCursorPos(); + + // verify cursor position in inline editor + expect(inlinePos).toEqual(this.infos["test1.css"].offsets[0]); + }); + }); it("should open a class selector", function () { initInlineTest("test1.html", 1);