From 4987b55ed6fc5789f3ca10179da32f1a3da5d954 Mon Sep 17 00:00:00 2001 From: inssein Date: Wed, 3 Jun 2015 16:49:38 -0700 Subject: [PATCH] formatted --- src/mixins/textbox_click_behavior.mixin.js | 2 +- src/shapes/textbox.class.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mixins/textbox_click_behavior.mixin.js b/src/mixins/textbox_click_behavior.mixin.js index 3f479ccf..8916fdef 100644 --- a/src/mixins/textbox_click_behavior.mixin.js +++ b/src/mixins/textbox_click_behavior.mixin.js @@ -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--; } diff --git a/src/shapes/textbox.class.js b/src/shapes/textbox.class.js index 912f9bea..073d9d4a 100644 --- a/src/shapes/textbox.class.js +++ b/src/shapes/textbox.class.js @@ -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; }