Skip to content

fix: Paginator.create_from_list no longer misses overflowing strings #1574

New issue

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

By clicking “No 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? No Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

ZeGmX
Copy link
Contributor

@ZeGmX ZeGmX commented Nov 27, 2023

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

When using Paginator.create_from_list with a list of strings that would exceed the page limit, the string that would cause the page overflow was removed, instead of being placed on the next page. This PR fixes this issue.

Changes

  • Modified Paginator.create_from_list so that overflowing strings (that are not longer than the page limit) are placed at the beginning of the next page, instead of being removed

Related Issues

Test Scenarios

Use the following code inside a command callback:

L = ["a" * 50, "b" * 50, "c" * 50, "d" * 50]
p = Paginator.create_from_list(client=bot, content=L, page_size=70)
await p.send(ctx, ephemeral=True)

Prior to this PR, executing the command would return two pages, with lines with a's and c's respectively. It now generates 4 pages, with one of the strings on each one.

L = ["a" * 90, "b" * 50, "c" * 50, "d" * 50]
p = Paginator.create_from_list(client=bot, content=L, page_size=70)
await p.send(ctx, ephemeral=True)

Prior to this PR, executing this command would lead to an empty first page, and a second page with the c's. Now it leads leads to three non-empty pages with the b's, c's and d's.

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

@Developer89899 Developer89899 merged commit a9147e5 into interactions-py:unstable Nov 30, 2023
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants