@@ -29,21 +29,21 @@ TextBufferCellIterator::TextBufferCellIterator(const TextBuffer& buffer, COORD p
2929// Arguments:
3030// - buffer - Pointer to screen buffer to seek through
3131// - pos - Starting position to retrieve text data from (within screen buffer bounds)
32- // - limits - Viewport limits to restrict the iterator within the buffer bounds (smaller than the buffer itself)
33- TextBufferCellIterator::TextBufferCellIterator (const TextBuffer& buffer, COORD pos, const Viewport limits ) :
32+ // - bounds - Viewport boundaries to restrict the iterator within the buffer bounds (smaller than the buffer itself)
33+ TextBufferCellIterator::TextBufferCellIterator (const TextBuffer& buffer, COORD pos, const Viewport bounds ) :
3434 _buffer(buffer),
3535 _pos(pos),
3636 _pRow(s_GetRow(buffer, pos)),
37- _bounds(limits ),
37+ _bounds(bounds ),
3838 _exceeded(false ),
3939 _view({}, {}, {}, TextAttributeBehavior::Stored),
4040 _attrIter(s_GetRow(buffer, pos)->GetAttrRow().cbegin())
4141{
4242 // Throw if the bounds rectangle is not limited to the inside of the given buffer.
43- THROW_HR_IF (E_INVALIDARG , !buffer.GetSize ().IsInBounds (limits ));
43+ THROW_HR_IF (E_INVALIDARG , !buffer.GetSize ().IsInBounds (bounds ));
4444
4545 // Throw if the coordinate is not limited to the inside of the given buffer.
46- THROW_HR_IF (E_INVALIDARG , !limits .IsInBounds (pos));
46+ THROW_HR_IF (E_INVALIDARG , !bounds .IsInBounds (pos));
4747
4848 _attrIter += pos.X ;
4949
@@ -55,18 +55,15 @@ TextBufferCellIterator::TextBufferCellIterator(const TextBuffer& buffer, COORD p
5555// Arguments:
5656// - buffer - Text buffer to seek through
5757// - pos - Starting position to retrieve text data from (within screen buffer bounds)
58- // - limits - Viewport limits to restrict the iterator within the buffer bounds (smaller than the buffer itself)
59- // - endPosInclusive - last position to iterate through (inclusive)
60- TextBufferCellIterator::TextBufferCellIterator (const TextBuffer& buffer, COORD pos, const Viewport limits , const COORD endPosInclusive ) :
61- TextBufferCellIterator(buffer, pos, limits )
58+ // - bounds - Viewport boundaries to restrict the iterator within the buffer bounds (smaller than the buffer itself)
59+ // - limit - last position to iterate through (inclusive)
60+ TextBufferCellIterator::TextBufferCellIterator (const TextBuffer& buffer, COORD pos, const Viewport bounds , const COORD limit ) :
61+ TextBufferCellIterator(buffer, pos, bounds )
6262{
6363 // Throw if the coordinate is not limited to the inside of the given buffer.
64- THROW_HR_IF (E_INVALIDARG , !_bounds.IsInBounds (endPosInclusive ));
64+ THROW_HR_IF (E_INVALIDARG , !_bounds.IsInBounds (limit ));
6565
66- // Throw if pos is past endPos
67- THROW_HR_IF (E_INVALIDARG , _bounds.CompareInBounds (pos, endPosInclusive) > 0 );
68-
69- _endPosInclusive = endPosInclusive;
66+ _limit = limit;
7067}
7168
7269// Routine Description:
@@ -92,7 +89,7 @@ bool TextBufferCellIterator::operator==(const TextBufferCellIterator& it) const
9289 _bounds == it._bounds &&
9390 _pRow == it._pRow &&
9491 _attrIter == it._attrIter &&
95- _endPosInclusive == _endPosInclusive ;
92+ _limit == _limit ;
9693}
9794
9895// Routine Description:
@@ -118,22 +115,22 @@ TextBufferCellIterator& TextBufferCellIterator::operator+=(const ptrdiff_t& move
118115 auto newPos = _pos;
119116 while (move > 0 && !_exceeded)
120117 {
121- // If we have an endPos , check if we've exceeded it
122- if (_endPosInclusive .has_value ())
118+ // If we have a limit , check if we've exceeded it
119+ if (_limit .has_value ())
123120 {
124- _exceeded = _bounds. CompareInBounds (newPos, *_endPosInclusive) > 0 ;
121+ _exceeded |= (newPos == _limit) ;
125122 }
126123
127- // If we already exceeded from endPos , we'll short-circuit and _not_ increment
124+ // If we already exceeded limit , we'll short-circuit and _not_ increment
128125 _exceeded |= !_bounds.IncrementInBounds (newPos);
129126 move--;
130127 }
131128 while (move < 0 && !_exceeded)
132129 {
133130 // If we have an endPos, check if we've exceeded it
134- if (_endPosInclusive .has_value ())
131+ if (_limit .has_value ())
135132 {
136- _exceeded = _bounds. CompareInBounds (newPos, *_endPosInclusive) < 0 ;
133+ _exceeded |= (newPos == _limit) ;
137134 }
138135
139136 // If we already exceeded from endPos, we'll short-circuit and _not_ decrement
0 commit comments