mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-17 05:06:46 +00:00
LibGUI: Add flag to TextDocument's word break locator methods
TextDocument::first_word_break_before was refactored out to be able to be used in multiple places throughout the project. It turns out that its behaviour needs to be slightly different depending on where its called, so it now has a start_at_column_before flag to decide which letter it "thinks" was clicked.
This commit is contained in:
committed by
Andreas Kling
parent
21b1aba03b
commit
4ad891a078
@@ -427,7 +427,7 @@ Optional<TextDocumentSpan> TextDocument::first_non_skippable_span_after(const Te
|
||||
return {};
|
||||
}
|
||||
|
||||
TextPosition TextDocument::first_word_break_before(const TextPosition& position) const
|
||||
TextPosition TextDocument::first_word_break_before(const TextPosition& position, bool start_at_column_before) const
|
||||
{
|
||||
if (position.column() == 0) {
|
||||
if (position.line() == 0) {
|
||||
@@ -439,7 +439,7 @@ TextPosition TextDocument::first_word_break_before(const TextPosition& position)
|
||||
|
||||
auto target = position;
|
||||
auto line = this->line(target.line());
|
||||
auto is_start_alphanumeric = isalnum(line.codepoints()[target.column() - 1]);
|
||||
auto is_start_alphanumeric = isalnum(line.codepoints()[target.column() - (start_at_column_before ? 1 : 0)]);
|
||||
|
||||
while (target.column() > 0) {
|
||||
auto next_codepoint = line.codepoints()[target.column() - 1];
|
||||
|
||||
Reference in New Issue
Block a user