mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 04:55:15 +00:00
LibGUI: Fix unpleasant selection behavior when dragging far to the left
If you select some text and drag the cursor outside the widget on the left hand side, we would previously suddenly snap the selection cursor to the end of the line instead of keeping it at the start of the line as you would expect. This patch fixes that. :^)
This commit is contained in:
parent
5c15c24976
commit
563a377f6b
Notes:
sideshowbarker
2024-07-19 07:26:01 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/563a377f6b5
1 changed files with 4 additions and 1 deletions
|
@ -163,7 +163,10 @@ TextPosition TextEditor::text_position_at(const Gfx::Point& a_position) const
|
|||
size_t column_index;
|
||||
switch (m_text_alignment) {
|
||||
case Gfx::TextAlignment::CenterLeft:
|
||||
column_index = (position.x() + glyph_width() / 2) / glyph_width();
|
||||
if (position.x() <= 0)
|
||||
column_index = 0;
|
||||
else
|
||||
column_index = (position.x() + glyph_width() / 2) / glyph_width();
|
||||
if (is_line_wrapping_enabled()) {
|
||||
for_each_visual_line(line_index, [&](const Gfx::Rect& rect, const StringView&, size_t start_of_line) {
|
||||
if (rect.contains_vertically(position.y())) {
|
||||
|
|
Loading…
Add table
Reference in a new issue