The issue here is as follows: The old code was not merging a the paragraph terminator when content was added. This left an extra terminator which caused all kinds of problems with the table code (I do not remember the details.) It’s also questionable whether it’s a good idea to preserve formatting in the terminator. mergeToPreviousIfPossible normally does not merge spans if there’s different formatting, but empty paragraph terminators are an exception and it always merges them even if the formatting is different.
I think the new behavior is more correct, but we’re going to have to handle pasting text as a special case because the code is assuming the text is not normalized which it now (sort-of) is.. On Sep 9, 2015, at 7:37 PM, Mihai Chira <mihai.ch...@gmail.com> wrote: > Hey guys (addressed to Piotr and Harbs), > > if you have time to take a look at this, it would really help. I have > a feeling you'd have much better ideas on how to go forward with the > fix. > > Many thanks! > > > ---------- Forwarded message ---------- > From: Mihai Chira (JIRA) <j...@apache.org> > Date: 9 September 2015 at 18:35 > Subject: [jira] [Comment Edited] (FLEX-34807) TLF - EditManager - > TextFlowEdit -insertTextScrap > To: iss...@flex.apache.org > > > > [ > https://issues.apache.org/jira/browse/FLEX-34807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14737128#comment-14737128 > ] > > Mihai Chira edited comment on FLEX-34807 at 9/9/15 4:35 PM: > ------------------------------------------------------------ > > *Investigation update*: this bug was (highly likely) introduced by > commit > [33df98ab9d2c69c84d4de6ab2ae969f9c5f93e35|https://fisheye6.atlassian.com/changelog/flex-tlf?cs=33df98ab9d2c69c84d4de6ab2ae969f9c5f93e35] > on the 5th Oct 2014. If I comment out the last if clause of > {{ParagraphElement.ensureTerminatorAfterReplace()}}, which was added > by that commit (and subsequently edited into its current form), the > bug disappears. That's because the algorithm in > {{TextFlowEdit.insertTextScrap()}} requires at least one > FlowLeafElement before which to add the pasted contents, and before > this bug was introduced, that used to be > {{ParagraphElement.terminatorSpan}}. But since the commit the > terminatorSpan has been merged into the previous span. > This seems to imply that there is an expectation in > {{TextFlowEdit.insertTextScrap()}} that {{destinationLeaf}} should > never be null (despite the null check in the line {code}insertPosition > = destinationLeaf ? destinationLeaf.getAbsoluteStart() : > textFlow.textLength - 1;{code}. > I imagine that just commenting out the code is not a viable solution, > as it will break other functionality. So we'll need either [~harbs] or > [~pete21] to throw in some thoughts, if they have the time. Much > appreciated. > > > was (Author: evolverine): > *Investigation update*: this bug was (highly likely) introduced by > commit > [33df98ab9d2c69c84d4de6ab2ae969f9c5f93e35|https://fisheye6.atlassian.com/changelog/flex-tlf?cs=33df98ab9d2c69c84d4de6ab2ae969f9c5f93e35] > on the 5th Oct 2014 by [~harbs]. If I comment out the last if clause > of {{ParagraphElement.ensureTerminatorAfterReplace()}}, which was > added by that commit (and subsequently edited into its current form), > the bug disappears. That's because the algorithm in > {{TextFlowEdit.insertTextScrap()}} requires at least one > FlowLeafElement before which to add the pasted contents, and before > this bug was introduced, that used to be > {{ParagraphElement.terminatorSpan}}. But since the commit the > terminatorSpan has been merged into the previous span. > This seems to imply that there is an expectation in > {{TextFlowEdit.insertTextScrap()}} that {{destinationLeaf}} should > never be null (despite the null check in the line {code}insertPosition > = destinationLeaf ? destinationLeaf.getAbsoluteStart() : > textFlow.textLength - 1;{code}. > I imagine that just commenting out the code is not a viable solution, > as it will break other functionality. So we'll need either [~harbs] or > [~pete21] to throw in some thoughts, if they have the time. Much > appreciated. > >> TLF - EditManager - TextFlowEdit -insertTextScrap >> ------------------------------------------------- >> >> Key: FLEX-34807 >> URL: https://issues.apache.org/jira/browse/FLEX-34807 >> Project: Apache Flex >> Issue Type: Bug >> Components: Spark: RichEditableText >> Affects Versions: Apache Flex 4.12.0, Apache Flex 4.13.0, Apache Flex >> 4.14.0 >> Reporter: Robbyn Gerhardt >> Assignee: Mihai Chira >> Labels: editmanager, richeditabletext, tlf >> Attachments: Bildschirmfoto 2015-03-19 um 15.28.19.png, >> Bildschirmfoto 2015-03-20 um 09.06.47.png, TextEditorTest.air, >> TextEditorTest.fxp >> >> >> 1. Copy Formatted text from RichEditableText Editor, see Image >> 2. Insert Formatted text from the clipboard with Ctrl + V in the editor. >> Then comes the error. >> TypeError: Error #1009: Cannot access a property or method of a null object >> reference. >> at >> flashx.textLayout.edit::TextFlowEdit$/insertTextScrap()[/Users/erik/Documents/ApacheFlex/git/flex-tlf/textLayout/src/flashx/textLayout/edit/TextFlowEdit.as:244] >> at >> flashx.textLayout.operations::PasteOperation/doOperation()[/Users/erik/Documents/ApacheFlex/git/flex-tlf/textLayout/src/flashx/textLayout/operations/PasteOperation.as:102] >> at >> flashx.textLayout.edit::EditManager/doInternal()[/Users/erik/Documents/ApacheFlex/git/flex-tlf/textLayout/src/flashx/textLayout/edit/EditManager.as:767] >> at >> flashx.textLayout.edit::EditManager/doOperation()[/Users/erik/Documents/ApacheFlex/git/flex-tlf/textLayout/src/flashx/textLayout/edit/EditManager.as:647] >> at >> flashx.textLayout.edit::EditManager/pasteTextScrap()[/Users/erik/Documents/ApacheFlex/git/flex-tlf/textLayout/src/flashx/textLayout/edit/EditManager.as:1806] >> at >> flashx.textLayout.edit::EditManager/editHandler()[/Users/erik/Documents/ApacheFlex/git/flex-tlf/textLayout/src/flashx/textLayout/edit/EditManager.as:270] >> at >> flashx.textLayout.container::ContainerController/editHandler()[/Users/erik/Documents/ApacheFlex/git/flex-tlf/textLayout/src/flashx/textLayout/container/ContainerController.as:2739] >> at >> flashx.textLayout.container::TextContainerManager/editHandler()[/Users/erik/Documents/ApacheFlex/git/flex-tlf/textLayout/src/flashx/textLayout/container/TextContainerManager.as:1876] >> at flash.display::NativeMenuItem/select() >> at flash.display::NativeMenuItem/performKeyEquivalent() >> at flash.display::NativeMenu/_menuItemPerformKeyEquivalent() >> at flash.display::NativeMenu/performKeyEquivalent() >> at flash.display::NativeMenuItem/_menuPerformKeyEquivalent() >> at flash.display::NativeMenuItem/performKeyEquivalent() >> at flash.display::NativeMenu/_menuItemPerformKeyEquivalent() >> at flash.display::NativeMenu/performKeyEquivalent() >> at flash.desktop::NativeApplication/_menuPerformKeyEquivalent() >> at flash.desktop::NativeApplication/_onKeyDownCapture() > > > > -- > This message was sent by Atlassian JIRA > (v6.3.4#6332)