diff --git a/src/extensions/default/UrlCodeHints/main.js b/src/extensions/default/UrlCodeHints/main.js index aa076a8a22c..db6480806bf 100644 --- a/src/extensions/default/UrlCodeHints/main.js +++ b/src/extensions/default/UrlCodeHints/main.js @@ -752,8 +752,6 @@ define(function (require, exports, module) { } else if (tagInfo.position.offset === 0) { completion = "\"" + completion + "\""; } - } else if (completion === tagInfo.attr.value) { - shouldReplace = false; } if (shouldReplace) { diff --git a/src/extensions/default/UrlCodeHints/testfiles/test.html b/src/extensions/default/UrlCodeHints/testfiles/test.html index 74a4b59067b..96e5b1f848d 100644 --- a/src/extensions/default/UrlCodeHints/testfiles/test.html +++ b/src/extensions/default/UrlCodeHints/testfiles/test.html @@ -23,5 +23,6 @@ Site-root relative: root folder Results + diff --git a/src/extensions/default/UrlCodeHints/unittests.js b/src/extensions/default/UrlCodeHints/unittests.js index 9ed0d13381c..cc8dd38b489 100644 --- a/src/extensions/default/UrlCodeHints/unittests.js +++ b/src/extensions/default/UrlCodeHints/unittests.js @@ -620,6 +620,34 @@ define(function (require, exports, module) { }); }); + it("should completely replace file in HTML", function () { + var pos1 = { line: 25, ch: 11 }, + pos2 = { line: 25, ch: 27 }, + pos3 = { line: 25, ch: 34 }; + + runs(function () { + testEditor.setCursorPos(pos2); + hintsObj = null; + expectAsyncHints(UrlCodeHints.hintProvider); + }); + + runs(function () { + expect(hintsObj).toBeTruthy(); + expect(hintsObj.hints).toBeTruthy(); + expect(hintsObj.hints.length).toBe(1); + expect(hintsObj.hints[0]).toBe("subfolder/chevron.png"); + + // False indicates hints were closed after insertion + expect(UrlCodeHints.hintProvider.insertHint(hintsObj.hints[0])).toBe(false); + + // File name was completely replaced, not just appended to + expect(testDocument.getRange(pos1, pos3)).toEqual("'subfolder/chevron.png'"); + + // Cursor was moved past closing single-quote + expect(testEditor.getCursorPos()).toEqual(pos3); + }); + }); + it("should insert filtered folder in HTML", function () { var pos1 = { line: 23, ch: 11 }, pos2 = { line: 23, ch: 14 },