diff options
author | Bram Moolenaar <Bram@vim.org> | 2005-12-18 22:10:00 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2005-12-18 22:10:00 +0000 |
commit | e3226be91a18160dcae6aefc240bf1d687bcd2a2 (patch) | |
tree | 038f14a1dc33c2598be03b661a0b7d6194001fca /src/popupmenu.c | |
parent | d35f9711d4558f8784e65531a152d38d1dabbe72 (diff) | |
download | vim-git-e3226be91a18160dcae6aefc240bf1d687bcd2a2.tar.gz |
updated for version 7.0173v7.0173
Diffstat (limited to 'src/popupmenu.c')
-rw-r--r-- | src/popupmenu.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/src/popupmenu.c b/src/popupmenu.c index 26c4ae77f..acc111ec2 100644 --- a/src/popupmenu.c +++ b/src/popupmenu.c @@ -237,12 +237,28 @@ pum_set_selected(n) if (pum_selected >= 0) { - if (pum_first > pum_selected) - /* scroll down */ - pum_first = pum_selected; - else if (pum_first < pum_selected - pum_height + 1) - /* scroll up */ - pum_first = pum_selected - pum_height + 1; + if (pum_first > pum_selected - 4) + { + /* scroll down; when we did a jump it's probably a PageUp then + * scroll to put the selected entry at the bottom */ + if (pum_first > pum_selected - 2) + { + pum_first = pum_selected - pum_height + 1; + if (pum_first < 0) + pum_first = 0; + } + else + pum_first = pum_selected; + } + else if (pum_first < pum_selected - pum_height + 5) + { + /* scroll up; when we did a jump it's probably a PageDown then + * scroll to put the selected entry at the top */ + if (pum_first < pum_selected - pum_height + 1 + 2) + pum_first = pum_selected; + else + pum_first = pum_selected - pum_height + 1; + } if (pum_height > 6) { @@ -298,4 +314,14 @@ pum_visible() return pum_array != NULL; } +/* + * Return the height of the popup menu, the number of entries visible. + * Only valid when pum_visible() returns TRUE! + */ + int +pum_get_height() +{ + return pum_height; +} + #endif |