Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/extensions/default/UrlCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/extensions/default/UrlCodeHints/testfiles/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
<a href='/'>Site-root relative: root folder</a>
<a href='test2.html'>Results</a>
<video poster=''>Results</video>
<img src='subfolder/chevron.png'>
</body>
</html>
28 changes: 28 additions & 0 deletions src/extensions/default/UrlCodeHints/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down