Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(705)

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js

Issue 2489403002: DevTools: Ghost text shouldn't affect textWithCurrentSuggestion (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js b/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
index edb4d88e508926af9147c95917997961db906c96..7ed2595dbbcae9fac571adaadd0f80b5c6a44fa3 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
@@ -151,14 +151,18 @@ WebInspector.TextPrompt = class extends WebInspector.Object {
* @return {string}
*/
textWithCurrentSuggestion() {
- return this._element.textContent;
+ var text = this.text();
+ if (!this._queryRange)
+ return text;
+ return text.substring(0, this._queryRange.startColumn) + this._currentSuggestion +
+ text.substring(this._queryRange.endColumn);
}
/**
* @return {string}
*/
text() {
- var text = this.textWithCurrentSuggestion();
+ var text = this._element.textContent;
if (this._ghostTextElement.parentNode) {
var addition = this._ghostTextElement.textContent;
text = text.substring(0, text.length - addition.length);
@@ -523,9 +527,7 @@ WebInspector.TextPrompt = class extends WebInspector.Object {
if (!this._queryRange)
return false;
- var text = this.text();
- this._element.textContent = text.substring(0, this._queryRange.startColumn) + this._currentSuggestion +
- text.substring(this._queryRange.endColumn);
+ this._element.textContent = this.textWithCurrentSuggestion();
this.setDOMSelection(
this._queryRange.startColumn + this._currentSuggestion.length,
this._queryRange.startColumn + this._currentSuggestion.length);
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698