mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-11 04:38:24 -06:00
Fix color selection off-by-one error and dangling Y-beam (#18798)
(cherry picked from commit 0b4f9662c7f459857b08ef70c2cfb2b6e682c6c5) Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgZYtao Service-Version: 1.23
This commit is contained in:
parent
cf3bbf53e6
commit
840f9623e5
@ -2061,14 +2061,6 @@ void TextBuffer::_ExpandTextRow(til::inclusive_rect& textRow) const
|
||||
}
|
||||
}
|
||||
|
||||
size_t TextBuffer::SpanLength(const til::point coordStart, const til::point coordEnd) const
|
||||
{
|
||||
const auto bufferSize = GetSize();
|
||||
// The coords are inclusive, so to get the (inclusive) length we add 1.
|
||||
const auto length = bufferSize.CompareInBounds(coordEnd, coordStart) + 1;
|
||||
return gsl::narrow<size_t>(length);
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - Retrieves the plain text data between the specified coordinates.
|
||||
// Arguments:
|
||||
|
||||
@ -199,8 +199,6 @@ public:
|
||||
std::wstring GetCustomIdFromId(uint16_t id) const;
|
||||
void CopyHyperlinkMaps(const TextBuffer& OtherBuffer);
|
||||
|
||||
size_t SpanLength(const til::point coordStart, const til::point coordEnd) const;
|
||||
|
||||
std::wstring GetPlainText(til::point start, til::point end) const;
|
||||
|
||||
struct CopyRequest
|
||||
|
||||
@ -2868,6 +2868,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// coloring other matches, then we need to make sure those get redrawn,
|
||||
// too.
|
||||
_renderer->TriggerRedrawAll();
|
||||
_updateSelectionUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1571,10 +1571,10 @@ void Terminal::SerializeMainBuffer(const wchar_t* destination) const
|
||||
|
||||
void Terminal::ColorSelection(const TextAttribute& attr, winrt::Microsoft::Terminal::Core::MatchMode matchMode)
|
||||
{
|
||||
const auto colorSelection = [this](const til::point coordStart, const til::point coordEnd, const TextAttribute& attr) {
|
||||
const auto colorSelection = [this](const til::point coordStartInclusive, const til::point coordEndExclusive, const TextAttribute& attr) {
|
||||
auto& textBuffer = _activeBuffer();
|
||||
const auto spanLength = textBuffer.SpanLength(coordStart, coordEnd);
|
||||
textBuffer.Write(OutputCellIterator(attr, spanLength), coordStart);
|
||||
const auto spanLength = textBuffer.GetSize().CompareInBounds(coordEndExclusive, coordStartInclusive, true);
|
||||
textBuffer.Write(OutputCellIterator(attr, spanLength), coordStartInclusive);
|
||||
};
|
||||
|
||||
for (const auto [start, end] : _GetSelectionSpans())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user