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

cache bufnr to prevent error while processing autoclose autocmd #576

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
8 changes: 6 additions & 2 deletions app/_static/highlight.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ github.com style (c) Vasily Polovnyov <[email protected]>
*/
:root {
--color-text-primary: #333;
--color-diff-add: #dfd;
--color-diff-remove: #fdd;
}
[data-theme="dark"] {
--color-text-primary: #c9d1d9;
--color-diff-add: #484;
--color-diff-remove: #844;
}

.hljs {
Expand Down Expand Up @@ -89,11 +93,11 @@ github.com style (c) Vasily Polovnyov <[email protected]>
}

.hljs-deletion {
background: #fdd;
background: var(--color-diff-remove);
}

.hljs-addition {
background: #dfd;
background: var(--color-diff-add);
}

.hljs-emphasis {
Expand Down
19 changes: 18 additions & 1 deletion app/_static/markdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@
content: normal;
}
.markdown-body code {
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
padding: 0;
padding-top: 0.2em;
padding-bottom: 0.2em;
Expand Down Expand Up @@ -303,9 +302,27 @@
box-sizing: border-box;
padding: 0;
}
.task-list-item input[type="checkbox"]:checked {
filter: invert() brightness(2.5) invert();
}
.task-list-item input[type="radio"] {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 0;
}
.octicon {
fill: var(--color-text-primary);
}
.mermaid {
display: flex;
justify-content: center;
}
.mermaid > svg {
max-width: none !important;
}
.dot {
display: flex;
justify-content: center;
align-items: center;
}
9 changes: 5 additions & 4 deletions autoload/mkdp/autocmd.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
" init preview key action
function! mkdp#autocmd#init() abort
execute 'augroup MKDP_REFRESH_INIT' . bufnr('%')
let s:bufnum = bufnr('%')
execute 'augroup MKDP_REFRESH_INIT' . s:bufnum
autocmd!
" refresh autocmd
if g:mkdp_refresh_slow
Expand All @@ -10,13 +11,13 @@ function! mkdp#autocmd#init() abort
endif
" autoclose autocmd
if g:mkdp_auto_close
autocmd BufHidden <buffer> call mkdp#rpc#preview_close()
autocmd BufHidden <buffer> call mkdp#rpc#preview_close(s:bufnum)
endif
" server close autocmd
autocmd VimLeave * call mkdp#rpc#stop_server()
augroup END
endfunction

function! mkdp#autocmd#clear_buf() abort
execute 'autocmd! ' . 'MKDP_REFRESH_INIT' . bufnr('%')
function! mkdp#autocmd#clear_buf(bufnum) abort
execute 'autocmd! ' . 'MKDP_REFRESH_INIT' . a:bufnum
endfunction
8 changes: 4 additions & 4 deletions autoload/mkdp/rpc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,18 @@ function! mkdp#rpc#preview_refresh() abort
endif
endfunction

function! mkdp#rpc#preview_close() abort
function! mkdp#rpc#preview_close(bufnum) abort
if s:is_vim
if s:mkdp_channel_id !=# v:null
call mkdp#rpc#notify(s:mkdp_channel_id, 'close_page', { 'bufnr': bufnr('%') })
call mkdp#rpc#notify(s:mkdp_channel_id, 'close_page', { 'bufnr': a:bufnum })
endif
else
if s:mkdp_channel_id !=# -1
call rpcnotify(s:mkdp_channel_id, 'close_page', { 'bufnr': bufnr('%') })
call rpcnotify(s:mkdp_channel_id, 'close_page', { 'bufnr': a:bufnum })
endif
endif
let b:MarkdownPreviewToggleBool = 0
call mkdp#autocmd#clear_buf()
call mkdp#autocmd#clear_buf(a:bufnum)
endfunction

function! mkdp#rpc#open_browser() abort
Expand Down