Menu

#12 Pasting - wrong position of cursor after pasting into list

closed
nobody
None
5
2009-05-25
2009-03-10
No

This patch fixes a bug:

BUG

To reproduce the bug: Create a list with a list item "AA" and with a nested list item "BB". Select a text without paragraphs such as "Hello" in a web browsers such as Firefox, press Control + C, place the cursor between the two As, and paste the text by pressing Control + V. The text is pasted as it should, but the cursor, after the pasting, is positioned between the two Bs.

The bug does not occur if the list item "AA" has no nested list item.

PATCH

To fix the bug, place the following text at the very end of the method SHTMLEditorPane.pasteHTML:

// We are somewhere else inside the paragraph to insert at.

String newHtml = pastedHTMLText.splitPaste(sDocument, characterElement, paragraphElement,
position, pasteHtmlTextModified, HTMLText.containsParagraphTags(pasteHtmlTextModified));
int paragraphOldEndOffset = paragraphElement.getEndOffset();
int oldCaretPosition = getCaretPosition();
sDocument.setOuterHTML(paragraphElement, newHtml);
Element newParagraphElement = getSHTMLDocument().getParagraphElement(oldCaretPosition);
// Place the caret after the pasted text
setCaretPosition(oldCaretPosition + newParagraphElement.getEndOffset() - paragraphOldEndOffset);

}

Discussion

  • Daniel Polansky

    Daniel Polansky - 2009-03-10

    Patch

     
  • Daniel Polansky

    Daniel Polansky - 2009-03-10

    I am attaching the patch as an attachment; the directly pasted patch looks odd.
    File Added: Pasting patch.txt

     
  • Daniel Polansky

    Daniel Polansky - 2009-05-25
    • status: open --> closed
     
  • Daniel Polansky

    Daniel Polansky - 2009-05-25

    Integrated in version 0.13.1.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.