Index: chrome_linux64/resources/inspector/CodeMirrorTextEditor.js |
=================================================================== |
--- chrome_linux64/resources/inspector/CodeMirrorTextEditor.js (revision 197568) |
+++ chrome_linux64/resources/inspector/CodeMirrorTextEditor.js (working copy) |
@@ -7021,7 +7021,7 @@ |
smartIndent: false, |
styleSelectedText: true, |
electricChars: false, |
- autoCloseBrackets: WebInspector.experimentsSettings.textEditorSmartBraces.isEnabled() |
+ autoCloseBrackets: true |
}); |
var extraKeys = {}; |
@@ -7064,16 +7064,32 @@ |
} |
WebInspector.CodeMirrorTextEditor.prototype = { |
+ |
+ undo: function() |
+ { |
+ this._codeMirror.undo(); |
+ }, |
+ |
+ redo: function() |
+ { |
+ this._codeMirror.redo(); |
+ }, |
+ |
_setupSelectionColor: function() |
{ |
if (WebInspector.CodeMirrorTextEditor._selectionStyleInjected) |
return; |
+ WebInspector.CodeMirrorTextEditor._selectionStyleInjected = true; |
+ var backgroundColor = WebInspector.getSelectionBackgroundColor(); |
+ var backgroundColorRule = backgroundColor ? ".CodeMirror .CodeMirror-selected { background-color: " + backgroundColor + ";}" : ""; |
+ var foregroundColor = WebInspector.getSelectionForegroundColor(); |
+ var foregroundColorRule = foregroundColor ? ".CodeMirror .CodeMirror-selectedtext { color: " + foregroundColor + "!important;}" : ""; |
+ if (!foregroundColorRule && !backgroundColorRule) |
+ return; |
+ |
var style = document.createElement("style"); |
- var backgroundColor = ".CodeMirror .CodeMirror-selected { background-color: " + WebInspector.getSelectionBackgroundColor() + ";}"; |
- var foregroundColor = ".CodeMirror .CodeMirror-selectedtext { color: " + WebInspector.getSelectionForegroundColor() + "!important;}"; |
- style.textContent = backgroundColor + foregroundColor; |
+ style.textContent = backgroundColorRule + foregroundColorRule; |
document.head.appendChild(style); |
- WebInspector.CodeMirrorTextEditor._selectionStyleInjected = true; |
}, |
/** |
@@ -7114,6 +7130,17 @@ |
return this._toRange(coords, coords); |
}, |
+ _convertTokenType: function(tokenType) |
+ { |
+ if (tokenType.startsWith("variable") || tokenType.startsWith("property") || tokenType === "def") |
+ return "javascript-ident"; |
+ if (tokenType === "string-2") |
+ return "javascript-regexp"; |
+ if (tokenType === "number" || tokenType === "comment" || tokenType === "string") |
+ return "javascript-" + tokenType; |
+ return null; |
+ }, |
+ |
/** |
* @param {number} lineNumber |
* @param {number} column |
@@ -7126,15 +7153,14 @@ |
var token = this._codeMirror.getTokenAt(new CodeMirror.Pos(lineNumber, column || 1)); |
if (!token || !token.type) |
return null; |
- var convertedType = null; |
- if (token.type.startsWith("variable") || token.type.startsWith("property") || token.type === "def") { |
- return { |
- startColumn: token.start, |
- endColumn: token.end - 1, |
- type: "javascript-ident" |
- }; |
- } |
- return null; |
+ var convertedType = this._convertTokenType(token.type); |
+ if (!convertedType) |
+ return null; |
+ return { |
+ startColumn: token.start, |
+ endColumn: token.end - 1, |
+ type: convertedType |
+ }; |
}, |
/** |
@@ -7225,7 +7251,7 @@ |
*/ |
defaultFocusedElement: function() |
{ |
- return this.element.firstChild; |
+ return this.element; |
}, |
focus: function() |