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

Unified Diff: Source/devtools/front_end/sources/SourcesView.js

Issue 378273004: DevTools: Add a shortcut for switching between files with the same name and different extensions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added a shortcut to shortcuts screen Created 6 years, 5 months 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
Index: Source/devtools/front_end/sources/SourcesView.js
diff --git a/Source/devtools/front_end/sources/SourcesView.js b/Source/devtools/front_end/sources/SourcesView.js
index f8ac80b41438939408b0982e74a5a5e6bc6b799e..0bfeb8743dca0e11651a9d1d4a2aee2ed256fb31 100644
--- a/Source/devtools/front_end/sources/SourcesView.js
+++ b/Source/devtools/front_end/sources/SourcesView.js
@@ -130,6 +130,18 @@ WebInspector.SourcesView.prototype = {
event.consume(true);
},
+ wasShown: function()
+ {
+ WebInspector.VBox.prototype.wasShown.call(this);
+ WebInspector.context.setFlavor(WebInspector.SourcesView, this);
+ },
+
+ willHide: function()
+ {
+ WebInspector.context.setFlavor(WebInspector.SourcesView, null);
+ WebInspector.VBox.prototype.willHide.call(this);
+ },
+
/**
* @return {!Element}
*/
@@ -683,6 +695,30 @@ WebInspector.SourcesView.prototype = {
this._editorContainer.view.element.classList.toggle("breakpoints-deactivated", !active);
},
+ _switchFile: function()
+ {
+ if (!this._currentUISourceCode)
+ return;
+ var uiSourceCodes = this._currentUISourceCode.project().uiSourceCodes();
+ var candidates = [];
+ var path = this._currentUISourceCode.parentPath();
+ var name = this._currentUISourceCode.name();
+ var namePrefix = name.substr(0, name.indexOf(".")) + ".";
apavlov 2014/07/09 14:06:05 var namePrefix = name.substr(0, name.indexOf(".")
lushnikov 2014/07/11 11:47:38 Let's get lastIndexOf
apavlov 2014/07/11 11:49:54 +1 So, var namePrefix = name.substr(0, name.lastIn
+ namePrefix = namePrefix.toLowerCase();
+ for (var i = 0; i < uiSourceCodes.length; ++i) {
+ var uiSourceCode = uiSourceCodes[i]
apavlov 2014/07/09 14:06:05 ';' missing
+ if (path === uiSourceCode.parentPath() && uiSourceCode.name().toLowerCase().startsWith(namePrefix))
+ candidates.push(uiSourceCode.name());
+ }
+ candidates.sort(String.naturalOrderComparator);
+ var index = mod(candidates.indexOf(name) + 1, candidates.length);
apavlov 2014/07/09 14:06:05 Do we want to be able to set up certain switching
+ var fullPath = path + "/" + candidates[index];
+ var nextUISourceCode = this._currentUISourceCode.project().uiSourceCode(fullPath);
+ if (!nextUISourceCode)
+ return;
+ this.showSourceLocation(nextUISourceCode);
+ },
+
__proto__: WebInspector.VBox.prototype
}
@@ -700,3 +736,25 @@ WebInspector.SourcesView.EditorAction.prototype = {
*/
button: function(sourcesView) { }
}
+
+/**
+ * @constructor
+ * @implements {WebInspector.ActionDelegate}
+ */
+WebInspector.SourcesView.SwitchFileActionDelegate = function()
+{
+}
+
+WebInspector.SourcesView.SwitchFileActionDelegate.prototype = {
+ /**
+ * @return {boolean}
+ */
+ handleAction: function()
+ {
+ var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView);
+ if (!sourcesView)
+ return false;
+ sourcesView._switchFile();
+ return true;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698