Fixed bug where rich text formatting isnt copied when selecting from a specific direction
This commit is contained in:
parent
e4efb2e78d
commit
8435816940
1 changed files with 12 additions and 9 deletions
|
|
@ -355,17 +355,17 @@ TextData TextBox::get_rich_text_data_between(TextPosition p1, TextPosition p2) {
|
||||||
toRet.paragraphs.back().pStyleData = paragraphs[pIndex].pStyleData;
|
toRet.paragraphs.back().pStyleData = paragraphs[pIndex].pStyleData;
|
||||||
}
|
}
|
||||||
|
|
||||||
toRet.tStyleMods.emplace_back(TextPosition{0, 0}, get_mods_used_at_pos(p1));
|
toRet.tStyleMods.emplace_back(TextPosition{0, 0}, get_mods_used_at_pos(start));
|
||||||
|
|
||||||
for(auto& [modPos, modifiers] : tStyleMods) {
|
for(auto& [modPos, modifiers] : tStyleMods) {
|
||||||
if(modPos <= p1)
|
if(modPos <= start)
|
||||||
continue;
|
continue;
|
||||||
else if(modPos > p2)
|
else if(modPos > end)
|
||||||
break;
|
break;
|
||||||
TextPosition insertPos;
|
TextPosition insertPos;
|
||||||
insertPos.fParagraphIndex = modPos.fParagraphIndex - p1.fParagraphIndex;
|
insertPos.fParagraphIndex = modPos.fParagraphIndex - start.fParagraphIndex;
|
||||||
if(modPos.fParagraphIndex == p1.fParagraphIndex)
|
if(modPos.fParagraphIndex == start.fParagraphIndex)
|
||||||
insertPos.fTextByteIndex = modPos.fTextByteIndex - p1.fTextByteIndex;
|
insertPos.fTextByteIndex = modPos.fTextByteIndex - start.fTextByteIndex;
|
||||||
else
|
else
|
||||||
insertPos.fTextByteIndex = modPos.fTextByteIndex;
|
insertPos.fTextByteIndex = modPos.fTextByteIndex;
|
||||||
toRet.tStyleMods.emplace_back(insertPos, modifiers);
|
toRet.tStyleMods.emplace_back(insertPos, modifiers);
|
||||||
|
|
@ -844,9 +844,12 @@ void TextBox::rebuild() {
|
||||||
heightOffset += pData.p->getHeight();
|
heightOffset += pData.p->getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
//std::cout << "size: " << tStyleMods.size() << std::endl;
|
//if(tStyleMods.size() != 0) {
|
||||||
//for(auto& s : tStyleMods)
|
// std::cout << "-------" << std::endl;
|
||||||
// std::cout << s.pos.fParagraphIndex << " " << s.pos.fTextByteIndex << std::endl;
|
// for(auto& s : tStyleMods)
|
||||||
|
// std::cout << s.pos.fParagraphIndex << " " << s.pos.fTextByteIndex << std::endl;
|
||||||
|
// std::cout << "size: " << tStyleMods.size() << std::endl;
|
||||||
|
//}
|
||||||
|
|
||||||
needsRebuild = false;
|
needsRebuild = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue