Modified: branches/safari-537.73-branch/Source/WebInspectorUI/ChangeLog (158587 => 158588)
--- branches/safari-537.73-branch/Source/WebInspectorUI/ChangeLog 2013-11-04 21:31:27 UTC (rev 158587)
+++ branches/safari-537.73-branch/Source/WebInspectorUI/ChangeLog 2013-11-04 21:38:11 UTC (rev 158588)
@@ -1,3 +1,7 @@
+2013-11-04 Lucas Forschler <[email protected]>
+
+ Rollout r154897
+
2013-10-31 Lucas Forschler <[email protected]>
Merge r156481
Modified: branches/safari-537.73-branch/Source/WebInspectorUI/UserInterface/CodeMirrorAdditions.js (158587 => 158588)
--- branches/safari-537.73-branch/Source/WebInspectorUI/UserInterface/CodeMirrorAdditions.js 2013-11-04 21:31:27 UTC (rev 158587)
+++ branches/safari-537.73-branch/Source/WebInspectorUI/UserInterface/CodeMirrorAdditions.js 2013-11-04 21:38:11 UTC (rev 158588)
@@ -281,17 +281,11 @@
return true;
});
- CodeMirror.defineExtension("alterNumberInRange", function(amount, startPosition, endPosition, updateSelection) {
+ CodeMirror.defineExtension("alterNumberInRange", function(amount, startPosition, endPosition, affectsSelection) {
// We don't try if the range is multiline, pass to another key handler.
if (startPosition.line !== endPosition.line)
return false;
- if (updateSelection) {
- // Remember the cursor position/selection.
- var selectionStart = this.getCursor("start");
- var selectionEnd = this.getCursor("end");
- }
-
var line = this.getLine(startPosition.line);
var foundPeriod = false;
@@ -359,20 +353,17 @@
this.replaceRange(alteredNumberString, from, to);
- if (updateSelection) {
- var previousLength = to.ch - from.ch;
- var newLength = alteredNumberString.length;
+ if (affectsSelection) {
+ var newTo = {line: startPosition.line, ch: from.ch + alteredNumberString.length};
// Fix up the selection so it follows the increase or decrease in the replacement length.
- if (previousLength != newLength) {
- if (selectionStart.line === from.line && selectionStart.ch > from.ch)
- selectionStart.ch += newLength - previousLength;
+ if (endPosition.ch >= to.ch)
+ endPosition = newTo;
- if (selectionEnd.line === from.line && selectionEnd.ch > from.ch)
- selectionEnd.ch += newLength - previousLength;
- }
+ if (startPosition.ch >= to.ch)
+ startPosition = newTo;
- this.setSelection(selectionStart, selectionEnd);
+ this.setSelection(startPosition, endPosition);
}
return true;
@@ -380,30 +371,10 @@
function alterNumber(amount, codeMirror)
{
- function findNumberToken(position)
- {
- // CodeMirror includes the unit in the number token, so searching for
- // number tokens is the best way to get both the number and unit.
- var token = codeMirror.getTokenAt(position);
- if (token && token.type && /\bnumber\b/.test(token.type))
- return token;
- return null;
- }
+ var startPosition = codeMirror.getCursor("anchor");
+ var endPosition = codeMirror.getCursor("head");
- var position = codeMirror.getCursor("head");
- var token = findNumberToken(position);
-
- if (!token) {
- // If the cursor is at the outside beginning of the token, the previous
- // findNumberToken wont find it. So check the next column for a number too.
- position.ch += 1;
- token = findNumberToken(position);
- }
-
- if (!token)
- return CodeMirror.Pass;
-
- var foundNumber = codeMirror.alterNumberInRange(amount, {ch: token.start, line: position.line}, {ch: token.end, line: position.line}, true);
+ var foundNumber = codeMirror.alterNumberInRange(amount, startPosition, endPosition, true);
if (!foundNumber)
return CodeMirror.Pass;
}