1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-18 18:02:37 +01:00

Fix 7344dfe651: Hang when clicking on a link in a text file. (#14539)

When text is not wrapped, a line's `wrapped_width` is 0, causing the Layouter to get stuck in an infinite loop.
This commit is contained in:
Peter Nelson
2025-08-26 18:28:16 +01:00
committed by GitHub
parent 995f30bff0
commit 68af94cf3e

View File

@@ -308,7 +308,7 @@ const TextfileWindow::Hyperlink *TextfileWindow::GetHyperlink(Point pt) const
/* Build line layout to figure out character position that was clicked. */
const Line &line = this->lines[line_index];
Layouter layout(line.text, line.wrapped_width, FS_MONO);
Layouter layout(line.text, line.wrapped_width == 0 ? INT32_MAX : line.wrapped_width, FS_MONO);
assert(subline < layout.size());
ptrdiff_t char_index = layout.GetCharAtPosition(pt.x - WidgetDimensions::scaled.frametext.left, subline);
if (char_index < 0) return nullptr;