Skip to content

fix(agenda): goto item with multiple tabpages#1149

Open
torgnylyon wants to merge 1 commit into
nvim-orgmode:masterfrom
torgnylyon:master
Open

fix(agenda): goto item with multiple tabpages#1149
torgnylyon wants to merge 1 commit into
nvim-orgmode:masterfrom
torgnylyon:master

Conversation

@torgnylyon
Copy link
Copy Markdown
Contributor

How to reproduce:

  1. open two tabpages
  2. in the first tabpage, open the agenda or todo list (there should now be three windows: in the first tabpage: an orgagenda and an empty buffer, in the second tabpage: an empty buffer)
  3. move cursor to an item in the agenda
  4. attempt to open item in split window ()

Expected result: the item should open in the window for the empty buffer in the first tabpage
Actual Result: the item opens in the window for the agenda

Having an org buffer in a window in the second tabpage will cause a similar effect. Also notice that the order of the tab pages matter for triggering the bug, as the search for a suitable window will pick the last window found, which will be in the second tabpage.

The bug is caused by the fact that win_id2win() will be called with the window id of the window found in the second tabpage, returning 0, making the command "0windcmd w" stay in the current window.

This patch fixes the issue by limiting the search for a suitable window to the current tabpage. A further improvement could be to break the for loops as soon a suitable window is found, but since that would only be noticeable when the current tabpage is already split in more than one window, and would break current behavior, it is left as is.

Summary

This PR adds fixes a bug in the agenda view.

Related Issues

None

Related #

Closes #

Changes

No major changes

Checklist

I confirm that I have:

  • Followed the
    Conventional Commits
    specification
    (e.g., feat: add new feature, fix: correct bug,
    docs: update documentation).
  • My PR title also follows the conventional commits specification.
  • Updated relevant documentation, if necessary.
  • Thoroughly tested my changes.
  • Added tests (if applicable) and verified existing tests pass with
    make test.
  • Checked for breaking changes and documented them, if any.

How to reproduce:
1. open two tabpages
2. in the first tabpage, open the agenda or todo list (there should now
   be three windows: in the first tabpage: an orgagenda and an empty
   buffer, in the second tabpage: an empty buffer)
3. move cursor to an item in the agenda
4. attempt to open item in split window (<TAB>)

Expected result: the item should open in the window for the empty buffer
in the first tabpage
Actual Result: the item opens in the window for the agenda

Having an org buffer in a window in the second tabpage will cause a
similar effect. Also notice that the order of the tab pages matter for
triggering the bug, as the search for a suitable window will pick the
last window found, which will be in the second tabpage.

The bug is caused by the fact that win_id2win() will be called with the
window id of the window found in the second tabpage, returning 0, making
the command "0windcmd w" stay in the current window.

This patch fixes the issue by limiting the search for a suitable window
to the current tabpage. A further improvement could be to break the for
loops as soon a suitable window is found, but since that would only be
noticeable when the current tabpage is already split in more than one
window, and would break current behavior, it is left as is.
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