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

Fix E474 error in minimap_buffer_enter_handler when opening minimap buffer without a file #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kuangyujing
Copy link

@kuangyujing kuangyujing commented Oct 6, 2024

Check list

  • I have read through the README (especially F.A.Q section)
  • I have searched through the existing issues or pull requests
  • I have verified all existing unit tests pass (See the README on how to run)
  • I have added new tests if appropriate
  • I have performed a self-review of my code and commented hard-to-understand areas
  • I have made corresponding changes to the documentation (when necessary)

Description

This commit addresses an issue where the minimap plugin would throw an "E474: Invalid argument" error when Vim is opened without a file and the minimap buffer is focused. The error was caused by attempting to move the cursor to an invalid position.

The fix adds a condition to s:minimap_buffer_enter_handler() to ensure s:last_pos is not empty or less than or equal to zero before calling cursor().

This resolves the issue by preventing the cursor from moving to an invalid position.

Issue: #199

Type of change

  • Bug fix
  • New feature
  • Improvement of existing features
  • Refactor
  • Breaking change
  • Documentation change
  • CI / CD

Test environment

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:
  • Vim
    • Neovim:
    • Vim: 9.1

@kuangyujing
Copy link
Author

Testify result:

* t/git_tests.vim
√ Git - Multiline diff
√ Git - Short file diff
√ Git - Long file diff
√ Git - Diff spans minimap lines
√ Git - Extras in string are ignored

* t/utility_tests.vim
√ Minimap conversion math works as expected
√ Opening minimap results in only one call to update_minimap

* t/search_tests.vim
√ Search setup
√ Search - Beginning of file
√ Search - Beginning of line
√ Search - End of line
√ Search - Multi match per line
√ Search - Spanning a line
√ Search - Many results
√ Search - Long Match
√ Search - History
√ Search tear down

* Test Summary
* ------------
* All tests successful
* Tests=17
* Result: PASS

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.

1 participant