Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2444: Fix wrapped lines search #2532

Merged
merged 8 commits into from
Nov 8, 2019
Merged

#2444: Fix wrapped lines search #2532

merged 8 commits into from
Nov 8, 2019

Conversation

glneto
Copy link
Contributor

@glneto glneto commented Nov 2, 2019

Issue

Wrapped lines are not being considered correctly in search. Because of that, findPrevious and findNext are skipping entries that match the searched pattern.

Proposed solution

I changed a bit how the findInLine works to use a SearchPosition object instead of param values.
That way we can update the startRow/startCol in the function and make sure the caller function will also consider them.

For reverse search:
The searchStart was being calculated incorrectly. Instead of using terminal.cols as the max value, we should consider that wrapped lines can have a startCol higher than this. (Ln. 163)

For regular search:
In case we have multiple entries of the search term in a single wrapped line, findNext was finding only the first entry. In case we find a wrapped line, we need to iterate back until we find the line start, while increasing the startCol. This will make us start the search in the correct line/col, and make sure we go through the whole wrapped line before going back to the start.

@Tyriar Tyriar added this to the 4.3.0 milestone Nov 7, 2019
@Tyriar Tyriar self-assigned this Nov 7, 2019
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @glneto, sorry about the delay though. I wrote up some thorough regression tests so this shouldn't happen again 🎉

@glneto
Copy link
Contributor Author

glneto commented Nov 7, 2019

Thanks @glneto, sorry about the delay though. I wrote up some thorough regression tests so this shouldn't happen again 🎉

that's amazing! thanks for going through all that :)

@Tyriar Tyriar merged commit dd4eb7b into xtermjs:master Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants