formatted

This commit is contained in:
inssein 2015-06-03 16:49:38 -07:00
parent bf7f2ea731
commit 4987b55ed6
2 changed files with 6 additions and 5 deletions

View file

@ -21,7 +21,7 @@
// were we at an end of a line that is wrapping?
var line = this._textLines[cursor.lineIndex];
if(cursor.charIndex === line.length - 1 && index !== this.text.length - 1 && this.text[index + 1] !== '\n') {
if (cursor.charIndex === line.length - 1 && index !== this.text.length - 1 && this.text[index + 1] !== '\n') {
index--;
}

View file

@ -104,11 +104,11 @@
* @returns {number}
* @private
*/
_measureText: function(ctx, text, lineIndex, charOffset) {
_measureText: function (ctx, text, lineIndex, charOffset) {
var width = 0, decl;
charOffset = charOffset || 0;
for(var i = charOffset; i < charOffset + text.length; i++) {
for (var i = charOffset; i < charOffset + text.length; i++) {
if (this.styles && this.styles[lineIndex] && (decl = this.styles[lineIndex][i])) {
ctx.save();
width += this._applyCharStylesGetWidth(ctx, text[i], lineIndex, i, decl);
@ -235,11 +235,12 @@
var line = this._textLines[i],
lineLen = line.length;
if(selectionStart <= removed + lineLen) {
if (selectionStart <= removed + lineLen) {
// edge case:
// If we are at the end of a line that is wrapping, force cursor on to next line
// However, doing that for inserting styles breaks things, so don't when text has changed
if(!textHasChanged && i !== numLines - 1 && selectionStart === removed + lineLen && this.text[removed + lineLen] !== '\n') {
if (!textHasChanged &&
i !== numLines - 1 && selectionStart === removed + lineLen && this.text[removed + lineLen] !== '\n') {
i++;
selectionStart = removed;
}