Skip to content

Fix history ranges starting past the end - #1778

Open
AryanRG wants to merge 1 commit into
python-cmd2:mainfrom
AryanRG:fix/history-range-past-end
Open

AryanRG wants to merge 1 commit into
python-cmd2:mainfrom
AryanRG:fix/history-range-past-end

Conversation

@AryanRG

@AryanRG AryanRG commented Oct 17, 2026

Copy link
Copy Markdown

History ranges that start past the last entry currently select the final command. For example,
after mark first and mark last, history --run 999: executes mark last again even though
the requested range contains no entries.

Allow the converted start index in History.span() to reach len(self) so these ranges are
empty. Add regressions for both range separators, boundary behavior, and command replay, plus
a changelog entry. The existing negative-index and inclusive-endpoint behavior is preserved.

Validation on macOS 27.0 arm64 / CPython 3.13.12:

  • The 14 added cases produced 10 failures and 4 passes on unchanged production source, then
    14 passes with the fix. The standalone replay reproduction also fails before and passes after.
  • make check: passed, including formatting, lint, ty, and mypy.
  • make test: 2,022 passed, 3 skipped; overall coverage 99.4%, history module coverage 100%.
  • make docs-test: strict build passed.
  • git diff --check: passed.

AI assistance was used for the investigation, patch, report, and validation. Hosted CI and
maintainer review are pending.

Closes #1777

@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.75%. Comparing base (93cfe81) to head (7193751).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1778   +/-   ##
=======================================
  Coverage   99.75%   99.75%           
=======================================
  Files          23       23           
  Lines        6473     6473           
=======================================
  Hits         6457     6457           
  Misses         16       16           
Flag Coverage Δ
unittests 99.75% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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.

History ranges starting past the end select and replay the last command

1 participant