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

Commit 361e81d

Browse files
author
Marcel Gerber
authored
Merge pull request #11284 from adobe/marcel/url-hints-replace
Replace the URL in URLCodeHints even if it is the current content of …
2 parents 6e9f9e6 + 90c878c commit 361e81d

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

src/extensions/default/UrlCodeHints/main.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,6 @@ define(function (require, exports, module) {
752752
} else if (tagInfo.position.offset === 0) {
753753
completion = "\"" + completion + "\"";
754754
}
755-
} else if (completion === tagInfo.attr.value) {
756-
shouldReplace = false;
757755
}
758756

759757
if (shouldReplace) {

src/extensions/default/UrlCodeHints/testfiles/test.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
<a href='/'>Site-root relative: root folder</a>
2424
<a href='test2.html'>Results</a>
2525
<video poster=''>Results</video>
26+
<img src='subfolder/chevron.png'>
2627
</body>
2728
</html>

src/extensions/default/UrlCodeHints/unittests.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,34 @@ define(function (require, exports, module) {
620620
});
621621
});
622622

623+
it("should completely replace file in HTML", function () {
624+
var pos1 = { line: 25, ch: 11 },
625+
pos2 = { line: 25, ch: 27 },
626+
pos3 = { line: 25, ch: 34 };
627+
628+
runs(function () {
629+
testEditor.setCursorPos(pos2);
630+
hintsObj = null;
631+
expectAsyncHints(UrlCodeHints.hintProvider);
632+
});
633+
634+
runs(function () {
635+
expect(hintsObj).toBeTruthy();
636+
expect(hintsObj.hints).toBeTruthy();
637+
expect(hintsObj.hints.length).toBe(1);
638+
expect(hintsObj.hints[0]).toBe("subfolder/chevron.png");
639+
640+
// False indicates hints were closed after insertion
641+
expect(UrlCodeHints.hintProvider.insertHint(hintsObj.hints[0])).toBe(false);
642+
643+
// File name was completely replaced, not just appended to
644+
expect(testDocument.getRange(pos1, pos3)).toEqual("'subfolder/chevron.png'");
645+
646+
// Cursor was moved past closing single-quote
647+
expect(testEditor.getCursorPos()).toEqual(pos3);
648+
});
649+
});
650+
623651
it("should insert filtered folder in HTML", function () {
624652
var pos1 = { line: 23, ch: 11 },
625653
pos2 = { line: 23, ch: 14 },

0 commit comments

Comments
 (0)