fix #1239 on('changeScrollTop') argument is an object instead of number

This commit is contained in:
nightwing 2013-02-09 15:36:01 +04:00
commit 2f55065e84
3 changed files with 34 additions and 33 deletions

View file

@ -360,31 +360,32 @@ bindCheckbox("read_only", function(checked) {
env.editor.setReadOnly(checked); env.editor.setReadOnly(checked);
}); });
var secondSession = null;
bindDropdown("split", function(value) { bindDropdown("split", function(value) {
var sp = env.split; var sp = env.split;
if (value == "none") { if (value == "none") {
if (sp.getSplits() == 2) {
secondSession = sp.getEditor(1).session;
}
sp.setSplits(1); sp.setSplits(1);
} else { } else {
var newEditor = (sp.getSplits() == 1); var newEditor = (sp.getSplits() == 1);
if (value == "below") { sp.setOrientation(value == "below" ? sp.BELOW : sp.BESIDE);
sp.setOrientation(sp.BELOW);
} else {
sp.setOrientation(sp.BESIDE);
}
sp.setSplits(2); sp.setSplits(2);
if (newEditor) { if (newEditor) {
var session = secondSession || sp.getEditor(0).session; var session = sp.getEditor(0).session;
var newSession = sp.setSession(session, 1); var newSession = sp.setSession(session, 1);
newSession.name = session.name; newSession.name = session.name;
} }
} }
}); });
function synchroniseScrolling() {
var s1 = env.split.$editors[0].session;
var s2 = env.split.$editors[1].session;
s1.on('changeScrollTop', function(pos) {s2.setScrollTop(pos)});
s2.on('changeScrollTop', function(pos) {s1.setScrollTop(pos)});
s1.on('changeScrollLeft', function(pos) {s2.setScrollLeft(pos)});
s2.on('changeScrollLeft', function(pos) {s1.setScrollLeft(pos)});
}
bindCheckbox("highlight_token", function(checked) { bindCheckbox("highlight_token", function(checked) {
var editor = env.editor; var editor = env.editor;
if (editor.tokenTooltip && !checked) { if (editor.tokenTooltip && !checked) {

View file

@ -997,11 +997,11 @@ var EditSession = function(text, mode) {
**/ **/
this.setScrollTop = function(scrollTop) { this.setScrollTop = function(scrollTop) {
scrollTop = Math.round(Math.max(0, scrollTop)); scrollTop = Math.round(Math.max(0, scrollTop));
if (this.$scrollTop === scrollTop) if (this.$scrollTop === scrollTop || isNaN(scrollTop))
return; return;
this.$scrollTop = scrollTop; this.$scrollTop = scrollTop;
this._emit("changeScrollTop", scrollTop); this._signal("changeScrollTop", scrollTop);
}; };
/** /**
@ -1018,11 +1018,11 @@ var EditSession = function(text, mode) {
**/ **/
this.setScrollLeft = function(scrollLeft) { this.setScrollLeft = function(scrollLeft) {
scrollLeft = Math.round(Math.max(0, scrollLeft)); scrollLeft = Math.round(Math.max(0, scrollLeft));
if (this.$scrollLeft === scrollLeft) if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft))
return; return;
this.$scrollLeft = scrollLeft; this.$scrollLeft = scrollLeft;
this._emit("changeScrollLeft", scrollLeft); this._signal("changeScrollLeft", scrollLeft);
}; };
/** /**

View file

@ -66,7 +66,7 @@ var EditSession = require("./edit_session").EditSession;
// automatically sorted list of ranges // automatically sorted list of ranges
this.rangeList = null; this.rangeList = null;
/** /**
* Adds a range to a selection by entering multiselect mode, if necessary. * Adds a range to a selection by entering multiselect mode, if necessary.
* @param {Range} range The new range to add * @param {Range} range The new range to add
* @param {Boolean} $blockChangeEvents Whether or not to block changing events * @param {Boolean} $blockChangeEvents Whether or not to block changing events
@ -218,7 +218,7 @@ var EditSession = require("./edit_session").EditSession;
var start = range.end, end = range.start; var start = range.end, end = range.start;
else else
var start = range.start, end = range.end; var start = range.start, end = range.end;
this.addRange(Range.fromPoints(end, end)); this.addRange(Range.fromPoints(end, end));
this.addRange(Range.fromPoints(start, start)); this.addRange(Range.fromPoints(start, start));
return; return;
@ -261,9 +261,9 @@ var EditSession = require("./edit_session").EditSession;
}; };
/** /**
* *
* Gets list of ranges composing rectangular block on the screen * Gets list of ranges composing rectangular block on the screen
* *
* @param {Cursor} screenCursor The cursor to use * @param {Cursor} screenCursor The cursor to use
* @param {Anchor} screenAnchor The anchor to use * @param {Anchor} screenAnchor The anchor to use
* @param {Boolean} includeEmptyLines If true, this includes ranges inside the block which are empty due to clipping * @param {Boolean} includeEmptyLines If true, this includes ranges inside the block which are empty due to clipping
@ -339,8 +339,8 @@ var EditSession = require("./edit_session").EditSession;
var Editor = require("./editor").Editor; var Editor = require("./editor").Editor;
(function() { (function() {
/** /**
* *
* Updates the cursor and marker layers. * Updates the cursor and marker layers.
* @method Editor.updateSelectionMarkers * @method Editor.updateSelectionMarkers
* *
@ -350,7 +350,7 @@ var Editor = require("./editor").Editor;
this.renderer.updateBackMarkers(); this.renderer.updateBackMarkers();
}; };
/** /**
* Adds the selection and cursor. * Adds the selection and cursor.
* @param {Range} orientedRange A range containing a cursor * @param {Range} orientedRange A range containing a cursor
* @returns {Range} * @returns {Range}
@ -368,7 +368,7 @@ var Editor = require("./editor").Editor;
return orientedRange; return orientedRange;
}; };
/** /**
* Removes the selection marker. * Removes the selection marker.
* @param {Range} The selection range added with [[Editor.addSelectionMarker `addSelectionMarker()`]]. * @param {Range} The selection range added with [[Editor.addSelectionMarker `addSelectionMarker()`]].
* @method Editor.removeSelectionMarker * @method Editor.removeSelectionMarker
@ -455,12 +455,12 @@ var Editor = require("./editor").Editor;
e.preventDefault(); e.preventDefault();
}; };
/** /**
* Executes a command for each selection range. * Executes a command for each selection range.
* @param {String} cmd The command to execute * @param {String} cmd The command to execute
* @param {String} args Any arguments for the command * @param {String} args Any arguments for the command
* @method Editor.forEachSelection * @method Editor.forEachSelection
**/ **/
this.forEachSelection = function(cmd, args) { this.forEachSelection = function(cmd, args) {
if (this.inVirtualSelectionMode) if (this.inVirtualSelectionMode)
return; return;
@ -491,7 +491,7 @@ var Editor = require("./editor").Editor;
this.onSelectionChange(); this.onSelectionChange();
}; };
/** /**
* Removes all the selections except the last added one. * Removes all the selections except the last added one.
* @method Editor.exitMultiSelectMode * @method Editor.exitMultiSelectMode
**/ **/
@ -522,7 +522,7 @@ var Editor = require("./editor").Editor;
if (this.$readOnly) if (this.$readOnly)
return; return;
this._emit("paste", text); this._signal("paste", text);
if (!this.inMultiSelectMode || this.inVirtualSelectionMode) if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
return this.insert(text); return this.insert(text);
@ -547,7 +547,7 @@ var Editor = require("./editor").Editor;
* @param {Object} The search options * @param {Object} The search options
* @param {Boolean} keeps * @param {Boolean} keeps
* *
* @returns {Number} The cumulative count of all found matches * @returns {Number} The cumulative count of all found matches
* @method Editor.findAll * @method Editor.findAll
**/ **/
this.findAll = function(needle, options, additive) { this.findAll = function(needle, options, additive) {
@ -575,11 +575,11 @@ var Editor = require("./editor").Editor;
/** /**
* Adds a cursor above or below the active cursor. * Adds a cursor above or below the active cursor.
* *
* @param {Number} dir The direction of lines to select: -1 for up, 1 for down * @param {Number} dir The direction of lines to select: -1 for up, 1 for down
* @param {Boolean} skip If `true`, removes the active selection range * @param {Boolean} skip If `true`, removes the active selection range
* *
* @method Editor.selectMoreLines * @method Editor.selectMoreLines
*/ */
this.selectMoreLines = function(dir, skip) { this.selectMoreLines = function(dir, skip) {
var range = this.selection.toOrientedRange(); var range = this.selection.toOrientedRange();
@ -619,7 +619,7 @@ var Editor = require("./editor").Editor;
this.selection.substractPoint(toRemove); this.selection.substractPoint(toRemove);
}; };
/** /**
* Transposes the selected ranges. * Transposes the selected ranges.
* @param {Number} dir The direction to rotate selections * @param {Number} dir The direction to rotate selections
* @method Editor.transposeSelections * @method Editor.transposeSelections
@ -661,7 +661,7 @@ var Editor = require("./editor").Editor;
} }
}; };
/** /**
* Finds the next occurence of text in an active selection and adds it to the selections. * Finds the next occurence of text in an active selection and adds it to the selections.
* @param {Number} dir The direction of lines to select: -1 for up, 1 for down * @param {Number} dir The direction of lines to select: -1 for up, 1 for down
* @param {Boolean} skip If `true`, removes the active selection range * @param {Boolean} skip If `true`, removes the active selection range
@ -688,7 +688,7 @@ var Editor = require("./editor").Editor;
this.multiSelect.substractPoint(range.cursor); this.multiSelect.substractPoint(range.cursor);
}; };
/** /**
* Aligns the cursors or selected text. * Aligns the cursors or selected text.
* @method Editor.alignCursors * @method Editor.alignCursors
**/ **/