This got a bit broken by the fix for https://github.com/wez/wezterm/issues/714 since we can be handed a range of logical line fragments, we should test each of them to find our matching result. Also, improve the logic for constraining the length when looking backwards.