-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplement TextBuffer::Reflow #15701
Changes from 1 commit
3d463f1
f725a6a
0230743
73833f8
6374aec
349082a
0fbb882
a72e2cb
4139230
1546a99
f7f7099
80e453d
a8ef491
5ad619d
fd4e89b
971cd79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -266,11 +266,16 @@ void ROW::TransferAttributes(const til::small_rle<TextAttribute, uint16_t, 1>& a | |
|
||
void ROW::CopyFrom(const ROW& source) | ||
{ | ||
RowCopyTextFromState state{ .source = source }; | ||
CopyTextFrom(state); | ||
TransferAttributes(source.Attributes(), _columnCount); | ||
_lineRendition = source._lineRendition; | ||
_wrapForced = source._wrapForced; | ||
|
||
RowCopyTextFromState state{ | ||
.source = source, | ||
.columnLimit = LineRenditionColumns(), | ||
}; | ||
CopyTextFrom(state); | ||
|
||
TransferAttributes(source.Attributes(), _columnCount); | ||
} | ||
|
||
// Returns the previous possible cursor position, preceding the given column. | ||
|
@@ -284,7 +289,17 @@ til::CoordType ROW::NavigateToPrevious(til::CoordType column) const noexcept | |
// Returns the row width if column is beyond the width of the row. | ||
til::CoordType ROW::NavigateToNext(til::CoordType column) const noexcept | ||
{ | ||
return _adjustForward(_clampedColumn(column + 1)); | ||
return _adjustForward(_clampedColumnInclusive(column + 1)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will allow us to "navigate" the cursor into the past-the-end column. |
||
} | ||
|
||
til::CoordType ROW::AdjustBackward(til::CoordType column) const noexcept | ||
{ | ||
return _adjustBackward(_clampedColumn(column)); | ||
} | ||
|
||
til::CoordType ROW::AdjustForward(til::CoordType column) const noexcept | ||
{ | ||
return _adjustForward(_clampedColumnInclusive(column)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These might warrant a comment as to why they're different than the
correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. I've removed |
||
|
||
uint16_t ROW::_adjustBackward(uint16_t column) const noexcept | ||
|
@@ -641,11 +656,12 @@ try | |
if (sourceColBeg < sourceColLimit) | ||
{ | ||
charOffsets = source._charOffsets.subspan(sourceColBeg, static_cast<size_t>(sourceColLimit) - sourceColBeg + 1); | ||
const auto charsOffset = charOffsets.front() & CharOffsetsMask; | ||
const auto beg = size_t{ charOffsets.front() } & CharOffsetsMask; | ||
const auto end = size_t{ charOffsets.back() } & CharOffsetsMask; | ||
// We _are_ using span. But C++ decided that string_view and span aren't convertible. | ||
// _chars is a std::span for performance and because it refers to raw, shared memory. | ||
#pragma warning(suppress : 26481) // Don't use pointer arithmetic. Use span instead (bounds.1). | ||
chars = { source._chars.data() + charsOffset, source._chars.size() - charsOffset }; | ||
chars = { source._chars.data() + beg, end - beg }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a |
||
} | ||
|
||
WriteHelper h{ *this, state.columnBegin, state.columnLimit, chars }; | ||
|
@@ -867,6 +883,16 @@ til::CoordType ROW::MeasureLeft() const noexcept | |
|
||
til::CoordType ROW::MeasureRight() const noexcept | ||
{ | ||
if (_wrapForced) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. brilliant |
||
{ | ||
auto width = _columnCount; | ||
if (_doubleBytePadded) | ||
{ | ||
width--; | ||
} | ||
return width; | ||
} | ||
|
||
const auto text = GetText(); | ||
const auto beg = text.begin(); | ||
const auto end = text.end(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change ensures that we take the line rendition into account when determining the capacity of the row in
CopyTextFrom
.