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

Commit

Permalink
Merge pull request #11284 from adobe/marcel/url-hints-replace
Browse files Browse the repository at this point in the history
Replace the URL in URLCodeHints even if it is the current content of …
  • Loading branch information
Marcel Gerber committed Jul 23, 2016
2 parents 6e9f9e6 + 90c878c commit 361e81d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
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

0 comments on commit 361e81d

Please sign in to comment.