Skip to content

Commit 0b4f966

Browse files
Fix color selection off-by-one error and dangling Y-beam (#18798)
1 parent 354e05d commit 0b4f966

File tree

4 files changed

+4
-13
lines changed

4 files changed

+4
-13
lines changed

src/buffer/out/textBuffer.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -2061,14 +2061,6 @@ void TextBuffer::_ExpandTextRow(til::inclusive_rect& textRow) const
20612061
}
20622062
}
20632063

2064-
size_t TextBuffer::SpanLength(const til::point coordStart, const til::point coordEnd) const
2065-
{
2066-
const auto bufferSize = GetSize();
2067-
// The coords are inclusive, so to get the (inclusive) length we add 1.
2068-
const auto length = bufferSize.CompareInBounds(coordEnd, coordStart) + 1;
2069-
return gsl::narrow<size_t>(length);
2070-
}
2071-
20722064
// Routine Description:
20732065
// - Retrieves the plain text data between the specified coordinates.
20742066
// Arguments:

src/buffer/out/textBuffer.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,6 @@ class TextBuffer final
199199
std::wstring GetCustomIdFromId(uint16_t id) const;
200200
void CopyHyperlinkMaps(const TextBuffer& OtherBuffer);
201201

202-
size_t SpanLength(const til::point coordStart, const til::point coordEnd) const;
203-
204202
std::wstring GetPlainText(til::point start, til::point end) const;
205203

206204
struct CopyRequest

src/cascadia/TerminalControl/ControlCore.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2868,6 +2868,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
28682868
// coloring other matches, then we need to make sure those get redrawn,
28692869
// too.
28702870
_renderer->TriggerRedrawAll();
2871+
_updateSelectionUI();
28712872
}
28722873
}
28732874
}

src/cascadia/TerminalCore/Terminal.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1571,10 +1571,10 @@ void Terminal::SerializeMainBuffer(const wchar_t* destination) const
15711571

15721572
void Terminal::ColorSelection(const TextAttribute& attr, winrt::Microsoft::Terminal::Core::MatchMode matchMode)
15731573
{
1574-
const auto colorSelection = [this](const til::point coordStart, const til::point coordEnd, const TextAttribute& attr) {
1574+
const auto colorSelection = [this](const til::point coordStartInclusive, const til::point coordEndExclusive, const TextAttribute& attr) {
15751575
auto& textBuffer = _activeBuffer();
1576-
const auto spanLength = textBuffer.SpanLength(coordStart, coordEnd);
1577-
textBuffer.Write(OutputCellIterator(attr, spanLength), coordStart);
1576+
const auto spanLength = textBuffer.GetSize().CompareInBounds(coordEndExclusive, coordStartInclusive, true);
1577+
textBuffer.Write(OutputCellIterator(attr, spanLength), coordStartInclusive);
15781578
};
15791579

15801580
for (const auto [start, end] : _GetSelectionSpans())

0 commit comments

Comments
 (0)