Skip to content

Commit

Permalink
Bidi: Fix handling of empty lines and deleting of the last run
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghabry committed Aug 24, 2024
1 parent 5452750 commit 4b97984
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/window_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,17 @@ void Window_Message::StartMessageProcessing(PendingMessage pm) {

int num_lines = 0;
auto append = [&](const std::vector<Text::Run>& runs) {
if (runs.back().direction == Text::Direction::RTL) {
text_runs.insert(text_runs.end(), runs.rbegin(), runs.rend());
line_direction.push_back(Text::Direction::RTL);
} else {
text_runs.insert(text_runs.end(), runs.begin(), runs.end());
if (runs.empty()) {
line_direction.push_back(Text::Direction::LTR);
} else {
if (runs.back().direction == Text::Direction::RTL) {
text_runs.insert(text_runs.end(), runs.rbegin(), runs.rend());
line_direction.push_back(Text::Direction::RTL);
}
else {
text_runs.insert(text_runs.end(), runs.begin(), runs.end());
line_direction.push_back(Text::Direction::LTR);
}
}

bool force_page_break = false;
Expand Down Expand Up @@ -198,7 +203,9 @@ void Window_Message::StartMessageProcessing(PendingMessage pm) {
}
//}

if (text_runs.empty() || text_runs.back().text.back() != '\f') {
if (text_runs.empty()) {
text_runs.push_back({"\f", Text::Direction::LTR});
} else if (text_runs.back().text.back() != '\f') {
text_runs.back().text += '\f';
}

Expand Down Expand Up @@ -581,7 +588,7 @@ void Window_Message::UpdateMessage() {
continue;
}

shape_ret.erase(shape_ret.end());
shape_ret.pop_back();
}

continue;
Expand Down

0 comments on commit 4b97984

Please sign in to comment.