Skip to content

Commit

Permalink
Extend selection start and end positions to coincide with highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
hrdl-github committed Jun 10, 2023
1 parent 0d441ff commit 0596adf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pdf_viewer/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void Document::fill_highlight_rects(fz_context* ctx, fz_document* doc_) {
std::vector<fz_rect> highlight_rects;
std::vector<fz_rect> merged_rects;
std::wstring highlight_text;
get_text_selection(ctx, highlight.selection_begin, highlight.selection_end, true, highlight_rects, highlight_text, doc_);
get_text_selection(ctx, highlight.selection_begin, highlight.selection_end, false, highlight_rects, highlight_text, doc_);
merge_selected_character_rects(highlight_rects, merged_rects);

if (i < highlights.size()) {
Expand Down
4 changes: 3 additions & 1 deletion pdf_viewer/document_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ void DocumentView::add_highlight(AbsoluteDocumentPos selection_begin, AbsoluteDo
get_text_selection(selection_begin, selection_end, is_word_selection, selected_characters, selected_text);
merge_selected_character_rects(selected_characters, merged_characters);
if (selected_text.size() > 0) {
current_document->add_highlight(selected_text, merged_characters, selection_begin, selection_end, type);
const fz_rect& rect1 = selected_characters.front();
const fz_rect& rect2 = selected_characters.back();
current_document->add_highlight(selected_text, merged_characters, {rect1.x0, (rect1.y0 + rect1.y1) / 2}, {rect2.x0, (rect2.y0 + rect2.y1) / 2}, type);
}
}
}
Expand Down

0 comments on commit 0596adf

Please sign in to comment.