Skip to content

Conversation

@noborus
Copy link
Owner

@noborus noborus commented Jan 17, 2026

Improved code clarity and maintainability by refactoring the document screen size update logic into a dedicated function.

Improved code clarity and maintainability by refactoring
the document screen size update logic into a dedicated function.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the document screen size update logic by extracting it into a dedicated updateDocumentSize() function, improving code maintainability and reducing duplication. The refactoring also includes improved variable naming in the status line drawing code.

Changes:

  • Extracted document size calculation into updateDocumentSize() function
  • Updated tests to set screen dimensions via root.scr.vWidth/vHeight instead of directly setting document width
  • Improved variable naming in drawRightStatus() for better clarity

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
oviewer/prepare_draw.go Added updateDocumentSize() function to encapsulate document size calculations; updated prepareScreen() and prepareDraw() to use the new function; changed minimum screen size from 1 to 2
oviewer/status_line.go Renamed variables str to numStr and width to numWidth for improved clarity
oviewer/prepare_draw_test.go Updated test setup to set root.scr.vWidth/vHeight before calling prepareScreen()
oviewer/move_leftright_test.go Updated multiple tests to set root.scr.vWidth instead of directly setting m.width

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

root.Doc.height = root.Doc.statusPos
// Do not allow very small screens.
root.scr.vWidth = max(root.scr.vWidth, 2)
root.scr.vHeight = max(root.scr.vHeight, 2)
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

The minimum screen size has been changed from 1 to 2. This change should be verified to ensure it doesn't cause issues with edge cases or existing behavior. Additionally, this appears to be an unrelated change that should ideally be in a separate commit or PR focused on changing minimum screen size requirements, rather than in a refactoring PR.

Suggested change
root.scr.vHeight = max(root.scr.vHeight, 2)
root.scr.vHeight = max(root.scr.vHeight, 1)

Copilot uses AI. Check for mistakes.
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