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

SliceFilter::doFilter does not work with ranges #30

Open
textshell opened this issue Oct 19, 2016 · 1 comment
Open

SliceFilter::doFilter does not work with ranges #30

textshell opened this issue Oct 19, 2016 · 1 comment

Comments

@textshell
Copy link

SliceFilter::doFilter tries splits the input into parts left and right from the ":" that divides the range to output.

  auto splitterIndex = argString.get().indexOf(QLatin1Char(':'));
  QString inputString = getSafeString(input);
  if (splitterIndex >= 0) {
    auto left = argString.get().left(splitterIndex).get().toInt();
    auto right = argString.get().right(splitterIndex).get().toInt();

But the right hand part is not correctly extracted, because QString::right expects the amount of characters from the right. It seems the code should be using QString::mid with the correct index adjustments instead.

Test cases:
data|slice:"0:10" returns the empty string, because it uses only "0" as right side.
data|slice:"00:-1" works because because "00" and "-1" are the same lenght.

@pcolby
Copy link
Contributor

pcolby commented Mar 20, 2018

OMG! Thank you so much for reporting the workaround (aka "Test cases") - saved me a lot of time!!

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

No branches or pull requests

2 participants