Skip to content

Commit ea6a6ea

Browse files
committed
Fixed ReleaseNotes scrolling issues
1 parent 2d6e6a5 commit ea6a6ea

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

plugin/markdown_extras.vim

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ endif
2020
if exists('g:markdown_extras_loaded') && g:markdown_extras_loaded
2121
finish
2222
endif
23+
g:markdown_extras_loaded = true
2324

24-
var release_notes =<< END
25-
# vim-markdown-extras: release notes
25+
const release_notes =<< END
2626

2727
## Links
2828
Links must have a valid URL format to keep consistency with
@@ -61,16 +61,42 @@ The default register is 'p' but that can be changed through the
6161
g:markdown_extras_config dictionary.
6262

6363

64-
Press <Esc> to close this popup.
64+
Press <Esc> or 'q' to close this popup.
6565
END
6666

67-
def ShowReleaseNotes()
6867

68+
def ReleaseNotesFilter(id: number, key: string): bool
69+
# To handle the keys when release notes popup is visible
70+
# Close
71+
if key ==# 'q' || key ==# "\<esc>"
72+
popup_close(id)
73+
# Move down
74+
elseif ["\<tab>", "\<C-n>", "\<Down>", "\<ScrollWheelDown>"]->index(key) != -1
75+
win_execute(id, "normal! \<c-e>")
76+
# Move up
77+
elseif ["\<S-Tab>", "\<C-p>", "\<Up>", "\<ScrollWheelUp>"]->index(key) != -1
78+
win_execute(id, "normal! \<c-y>")
79+
# Jump down
80+
elseif key == "\<C-f>"
81+
win_execute(id, "normal! \<c-f>")
82+
# Jump up
83+
elseif key == "\<C-b>"
84+
win_execute(id, "normal! \<c-b>")
85+
else
86+
return false
87+
endif
88+
return true
89+
enddef
90+
91+
def ShowReleaseNotes()
92+
const title = ' vim-markdown-extras: release notes '
6993
const popup_options = {
70-
border: [1, 1, 1, 1],
71-
borderchars: ['', '', '', '', '', '', '', ''],
72-
filter: 'popup_filter_menu',
73-
}
94+
border: [1, 1, 1, 1],
95+
borderchars: ['', '', '', '', '', '', '', ''],
96+
scrollbar: false,
97+
title: title,
98+
filter: ReleaseNotesFilter
99+
}
74100

75101
const popup_id = popup_create(release_notes, popup_options)
76102
win_execute(popup_id, 'set filetype=markdown')
@@ -167,5 +193,3 @@ enddef
167193
command! -nargs=1 -complete=file MDEPathToURL PathToURLReg(<f-args>)
168194
command! -nargs=0 MDEReleaseNotes ShowReleaseNotes()
169195
command! -nargs=? MDEIndex indices.ShowIndex(<f-args>)
170-
171-
g:markdown_extras_loaded = true

0 commit comments

Comments
 (0)