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

Commit 933b009

Browse files
committed
Merge pull request #11869 from adobe/abose/instantAfterPaste
Remember last searched phrase & instant search paste fix.
2 parents 3d6fdc9 + 30716f4 commit 933b009

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/search/FindBar.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ define(function (require, exports, module) {
5353
var lastTypedTime = 0,
5454
currentTime = 0,
5555
intervalId = 0,
56-
lastQueriedText = "";
56+
lastQueriedText = "",
57+
lastTypedText = "",
58+
lastKeyCode;
5759

5860
/**
5961
* @constructor
@@ -92,6 +94,7 @@ define(function (require, exports, module) {
9294
this._closed = false;
9395
this._enabled = true;
9496
this.lastQueriedText = "";
97+
this.lastTypedText = "";
9598
}
9699
EventDispatcher.makeEventDispatcher(FindBar.prototype);
97100

@@ -267,6 +270,7 @@ define(function (require, exports, module) {
267270
$root
268271
.on("input", "#find-what", function () {
269272
self.trigger("queryChange");
273+
lastTypedText = self.getQueryInfo().query;
270274
})
271275
.on("click", "#find-case-sensitive, #find-regexp", function (e) {
272276
$(e.currentTarget).toggleClass("active");
@@ -278,6 +282,7 @@ define(function (require, exports, module) {
278282
})
279283
.on("keydown", "#find-what, #replace-with", function (e) {
280284
lastTypedTime = new Date().getTime();
285+
lastKeyCode = e.keyCode;
281286
var executeSearchIfNeeded = function () {
282287
// We only do instant search via node.
283288
if (FindUtils.isNodeSearchDisabled() || FindUtils.isInstantSearchDisabled()) {
@@ -289,7 +294,7 @@ define(function (require, exports, module) {
289294
}
290295
currentTime = new Date().getTime();
291296
if (lastTypedTime && (currentTime - lastTypedTime >= 100) && self.getQueryInfo().query !== lastQueriedText &&
292-
!FindUtils.isNodeSearchInProgress() && e.keyCode !== KeyEvent.DOM_VK_CONTROL) {
297+
!FindUtils.isNodeSearchInProgress()) {
293298
// init Search
294299
if (self._options.multifile) {
295300
if ($(e.target).is("#find-what")) {
@@ -308,6 +313,7 @@ define(function (require, exports, module) {
308313
if (e.keyCode === KeyEvent.DOM_VK_RETURN) {
309314
e.preventDefault();
310315
e.stopPropagation();
316+
lastQueriedText = self.getQueryInfo().query;
311317
if (self._options.multifile) {
312318
if ($(e.target).is("#find-what")) {
313319
if (self._options.replace) {
@@ -566,7 +572,7 @@ define(function (require, exports, module) {
566572
* @return {query: string, replaceText: string} Query and Replace text to prepopulate the Find Bar with
567573
*/
568574
FindBar.getInitialQuery = function (currentFindBar, editor) {
569-
var query = "",
575+
var query = lastTypedText,
570576
replaceText = "";
571577

572578
/*
@@ -598,7 +604,7 @@ define(function (require, exports, module) {
598604
query = openedFindBar.getQueryInfo().query;
599605
replaceText = openedFindBar.getReplaceText();
600606
} else if (editor) {
601-
query = getInitialQueryFromSelection(editor);
607+
query = getInitialQueryFromSelection(editor) || lastTypedText;
602608
}
603609
}
604610

src/search/SearchResultsView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ define(function (require, exports, module) {
361361
);
362362

363363
this._$summary.html(Mustache.render(searchSummaryTemplate, {
364-
query: (this._model.queryInfo.query && this._model.queryInfo.query.toString()) || "",
364+
query: (this._model.queryInfo && this._model.queryInfo.query && this._model.queryInfo.query.toString()) || "",
365365
replaceWith: this._model.replaceText,
366366
titleLabel: this._model.isReplace ? Strings.FIND_REPLACE_TITLE_LABEL : Strings.FIND_TITLE_LABEL,
367367
scope: this._model.scope ? " " + FindUtils.labelForScope(this._model.scope) + " " : "",

0 commit comments

Comments
 (0)