GRAPHICS: MACGUI: MacText: Fix selection condition

Outside the while loop we only check pos > 0 once.
This commit is contained in:
Nathanael Gentry 2020-07-31 01:02:58 -04:00
parent 1ef07ff5dd
commit 4c996feb5d

View File

@ -1037,6 +1037,7 @@ void MacText::setSelection(int pos, bool start) {
int row = 0, col = 0;
int colX = 0;
if (pos > 0) {
while (pos > 0) {
if (pos < getLineCharWidth(row)) {
for (uint i = 0; i < _textLines[row].chunks.size(); i++) {
@ -1053,7 +1054,7 @@ void MacText::setSelection(int pos, bool start) {
}
break;
} else {
pos -= getLineCharWidth(row) + (row ? 1 : 0);
pos -= getLineCharWidth(row) + 1; // (row ? 1 : 0);
}
row++;
@ -1064,8 +1065,7 @@ void MacText::setSelection(int pos, bool start) {
break;
}
}
if (pos == -1) {
} else {
row = _textLines.size() - 1;
colX = _surface->w;
col = getLineCharWidth(row);