Fix selection rendering (#4830)

The rendering of selections was not aligned to the actual selection that took place for newlines at the end of messages, if they were the only part that was selected of that message.

In addition to that fix, we've already refactored the MessageLayoutContainer to try to make it a little bit more sane to work with in the future.

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix
2023-09-23 17:09:56 +02:00
committed by GitHub
parent c71e91200a
commit 6860c7007e
9 changed files with 886 additions and 657 deletions
+5 -4
View File
@@ -1,5 +1,6 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <tuple>
#include <utility>
@@ -7,12 +8,12 @@
namespace chatterino {
struct SelectionItem {
uint32_t messageIndex{0};
uint32_t charIndex{0};
size_t messageIndex{0};
size_t charIndex{0};
SelectionItem() = default;
SelectionItem(uint32_t _messageIndex, uint32_t _charIndex)
SelectionItem(size_t _messageIndex, size_t _charIndex)
: messageIndex(_messageIndex)
, charIndex(_charIndex)
{
@@ -73,7 +74,7 @@ struct Selection {
}
// Shift all message selection indices `offset` back
void shiftMessageIndex(uint32_t offset)
void shiftMessageIndex(size_t offset)
{
if (offset > this->selectionMin.messageIndex)
{