#THE PROMPT: This file (uploaded) is the Scribus source code. Analyse this deeply. How much code change the following fix need: When there are two paragraphs PARA1 and PARA2. PARA1 one is given a paragraph style STYLE1 and PARA2 is given STYLE2. When you put cursor in the start of the PARA2 and press backspace (so that PARA2 now merges with PARA1), PARA1 now takes the STYLE2, it should be so that the new PARA resulting from the merger of the two) should stay in STYLE1 instead. After all PARA2 came and mergedd with PARA1. PARA1 did not go anywhere, it's style should also not change. #AI EXPLAINED: I analysed the uploaded Scribus source. This is not a large feature. It is a small-to-medium text-model bug fix, but it must be done carefully because of undo/redo. The bug is mainly here: scribus/text/storytext.cpp Scribus stores paragraph style on the paragraph separator after the paragraph: PARA1 [PARSEP carrying STYLE1] PARA2 [STYLE2 / trailingStyle] When Backspace is pressed at the start of PARA2, Scribus deletes the PARSEP between them. That separator is also where STYLE1 lives. So after deletion, the merged paragraph is left using STYLE2. ##Current flow: PageItem_TextFrame::handleModeEditKey() Backspace selects previous character deleteSelectedTextFromFrame() PageItem_TextFrame::deleteSelectedTextFromFrame() itemText.removeSelection() StoryText::removeSelection() removeChars() StoryText::removeChars() if char is PARSEP: removeParSep() StoryText::removeParSep() deletes paragraph style attached to that PARSEP then reassigns char context from paragraphStyle(pos + 1) That last part is the core problem: paragraphStyle(pos + 1) is effectively the style of the right paragraph, i.e. STYLE2. ##Code change estimate ###Bad/simple fix A very small patch could be made in: scribus/pageitem_textframe.cpp around the Backspace handler: case Qt::Key_Backspace: Capture STYLE1 before deleting the separator, then apply it after deletion. That would be around 10–20 lines. But I would not recommend that as the real fix, because undo/redo would likely become wrong. Undo currently relies on the old behaviour where the right paragraph’s style survives after deletion. ###Proper fix A proper fix should be in the text model, not just the keyboard handler. Expected files touched: scribus/text/storytext.cpp scribus/text/storytext.h scribus/pageitem_textframe.cpp scribus/pageitem.cpp scribus/tests/testStoryText.cpp scribus/tests/testStoryText.h Realistic size: Core code: ~50–70 changed lines Tests included: ~85–100 changed lines total So: small patch, but central text-model logic. ###What the proper fix should do When deleting a paragraph separator: PARA1 STYLE1 + PARA2 STYLE2 the text model should detect whether the deletion is a real merge: PARA1PARA2 If yes, move/preserve the left paragraph style onto the resulting paragraph: merged paragraph keeps STYLE1 But it must not blindly preserve the left style in all cases. For example, if the user selects and deletes the whole first paragraph: [PARA1 + separator deleted] PARA2 then PARA2 should probably keep STYLE2, not inherit deleted STYLE1. So the fix needs this distinction: Deleting only the separator / merging into left paragraph: keep left style Deleting the whole left paragraph: keep right style ###Undo/redo issue This is why the patch is not just 10 lines. Currently, when deleting a paragraph separator, undo stores only the deleted separator’s paragraph style: ip->setItem(itemText.paragraphStyle(i)); That is not enough after changing the merge behaviour. A correct undo needs to know both: left paragraph style = STYLE1 right paragraph style = STYLE2 So the undo state for DELETE_FRAMEPARA should store both styles, probably as something like: QPair Then undo can restore: PARA1 -> STYLE1 PARA2 -> STYLE2 while redo again merges to: PARA1PARA2 -> STYLE1 My verdict This is a good candidate for a clean developer patch. It is not a UI feature and does not need large refactoring. The main change is in StoryText::removeParSep() / StoryText::removeChars(), with undo support in deleteSelectedTextFromFrame() and restoreDeleteFrameParagraph(). So: When deleting a paragraph separator as a merge operation, Scribus currently drops the left paragraph’s style because the style is stored on the separator being removed. The merged paragraph should retain the left paragraph’s style. The fix should preserve the left style only for true merge deletions and update DELETE_FRAMEPARA undo data so undo restores both original paragraph styles. #ASKED IT TO WRITE A PROPER PATCH AND IT CREATED ONE: ##What it changes: scribus/text/storytext.cpp scribus/text/storytext.h scribus/pageitem_textframe.cpp scribus/pageitem.cpp scribus/tests/testStoryText.cpp scribus/tests/testStoryText.h ##Core behaviour fixed: PARA1 STYLE1 + PARA2 STYLE2 Backspace at start of PARA2 Merged paragraph keeps STYLE1 Undo/redo is handled by changing DELETE_FRAMEPARA undo data from storing only one ParagraphStyle to storing: QPair ##So undo can restore: left paragraph -> STYLE1 right paragraph -> STYLE2 The patch also adds two StoryText tests: removeParSepKeepsLeftParagraphStyle() removeWholeLeftParagraphKeepsRightParagraphStyle() I did not compile full Scribus here, but the patch is structurally clean and applies cleanly to the uploaded source.