Index: Source/devtools/front_end/documentation/DocumentationView.js |
diff --git a/Source/devtools/front_end/documentation/DocumentationView.js b/Source/devtools/front_end/documentation/DocumentationView.js |
index 501a9d689c841e2ed282d32782d4a41c0edf822a..8078fe3914db48aeccce5d7c8d08a3aeca5546f6 100644 |
--- a/Source/devtools/front_end/documentation/DocumentationView.js |
+++ b/Source/devtools/front_end/documentation/DocumentationView.js |
@@ -50,18 +50,25 @@ WebInspector.DocumentationView.ContextMenuProvider.prototype = { |
if (!(target instanceof WebInspector.CodeMirrorTextEditor)) |
return; |
var textEditor = /** @type {!WebInspector.CodeMirrorTextEditor} */ (target); |
- contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Show documentation" : "Show Documentation"), this._showDocumentation.bind(this, textEditor)); |
+ var selectedText = this._getSelection(textEditor); |
apavlov
2014/08/11 15:04:14
Blink does not use "get" prefixes. This should be
|
+ if (!selectedText) |
+ return; |
+ var urlProvider = new WebInspector.DocumentationURLProvider(); |
apavlov
2014/08/11 15:04:14
Can we make it a singleton? It has no state
semeny
2014/08/11 15:34:28
Did not really understand what is wrong and what s
|
+ var itemPath = urlProvider.itemPath(selectedText); |
+ if (!itemPath) |
+ return; |
+ contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Show documentation" : "Show Documentation"), WebInspector.DocumentationView.showSearchTerm.bind(null, selectedText)); |
}, |
/** |
* @param {!WebInspector.CodeMirrorTextEditor} textEditor |
+ * @return {?string} |
*/ |
- _showDocumentation: function(textEditor) |
+ _getSelection: function(textEditor) |
lushnikov
2014/08/11 14:59:47
no need for the separate function - please, inline
semeny
2014/08/11 15:34:28
Done.
|
{ |
var selection = textEditor.selection(); |
- if (!selection || selection.isEmpty()) |
- return; |
- var selectedText = textEditor.copyRange(selection); |
- WebInspector.DocumentationView.showSearchTerm(selectedText); |
+ if (!selection || selection.isEmpty() || selection.startLine !== selection.endLine) |
apavlov
2014/08/11 15:04:14
Shouldn't this detect the word at cursor if the se
semeny
2014/08/11 15:34:28
No, only if property is selected.
|
+ return null; |
+ return textEditor.copyRange(selection); |
} |
-} |
+} |