From c2fefc924c3eb1549280f31f426a399f002d1da6 Mon Sep 17 00:00:00 2001 From: John Burns Date: Sat, 20 Feb 2021 10:38:40 +0000 Subject: [PATCH] fix for #6841 --- src/mixins/itext_behavior.mixin.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mixins/itext_behavior.mixin.js b/src/mixins/itext_behavior.mixin.js index c523578ebdb..4d075b4f4a4 100644 --- a/src/mixins/itext_behavior.mixin.js +++ b/src/mixins/itext_behavior.mixin.js @@ -866,7 +866,13 @@ this.insertCharStyleObject(cursorLoc.lineIndex + i, 0, addedLines[i], copiedStyle); } else if (copiedStyle) { - this.styles[cursorLoc.lineIndex + i][0] = copiedStyle[0]; + // this test is required in order to close #6841 + // when a pasted buffer begins with a newline then + // this.styles[cursorLoc.lineIndex + i] and copiedStyle[0] + // may be undefined for some reason + if (this.styles[cursorLoc.lineIndex + i] && copiedStyle[0]) { + this.styles[cursorLoc.lineIndex + i][0] = copiedStyle[0]; + } } copiedStyle = copiedStyle && copiedStyle.slice(addedLines[i] + 1); }