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

readline: fix issue with newline-less last line #47317

Merged
merged 4 commits into from
Apr 14, 2023

Commits on Mar 30, 2023

  1. readline: fix issue with newline-less last line

    The logic for reading lines was slightly flawed, in that it assumed
    there would be a final new line. It handled the case where there are no
    new lines, but this then broke if there were some new lines.
    
    The fix in logic is basically removing the special case where there are
    no new lines by changing it to always read the final line with no new
    lines. This works because if a file contains no new lines, the final
    line is the first line, and all is well.
    
    There is some subtlety in this functioning, however. If the last line
    contains no new lines, then `lastIndex` will be the start of the last
    line, and `kInsertString` will be called from that point. If it does
    contain a new line, `lastIndex` will be equal to `s.length`, so the
    slice will be the empty string.
    
    Fixes: nodejs#47305
    harrisi committed Mar 30, 2023
    Configuration menu
    Copy the full SHA
    44c465c View commit details
    Browse the repository at this point in the history

Commits on Apr 2, 2023

  1. add repl and readline tests

    The repl test probably isn't strictly necessary, but this area's tests
    has been lacking sufficiently varying cases which have caused a few bugs
    to be missed, so it seems reasonable to include.
    harrisi committed Apr 2, 2023
    Configuration menu
    Copy the full SHA
    c04075a View commit details
    Browse the repository at this point in the history
  2. fix lint issues

    harrisi committed Apr 2, 2023
    Configuration menu
    Copy the full SHA
    a407b73 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    70fa0c7 View commit details
    Browse the repository at this point in the history