vim-markdown-toc icon indicating copy to clipboard operation
vim-markdown-toc copied to clipboard

Prettier gaurds move

Open idvorkin opened this issue 5 years ago • 8 comments
trafficstars

I’m not sure what is going on or the exact repro. The symptom is sometimes the prettier gaurds that were around my toc marks move. A “phychic debugging” is the toc is written a few lines below it’s original line. I’ve tried a few things to isolate this, but haven’t found a consistent repro. I think it’s more likely if I hit save above the TOC, as opposed to below it, but sometimes I get a repro below as well. See video.

A6D283B8-641C-40B9-A18F-8B1DE3337155

idvorkin avatar Mar 08 '20 18:03 idvorkin

I’d like ideas on how to debug this (via logs or something)

idvorkin avatar Mar 08 '20 18:03 idvorkin

Pushing to top, I now have more insight on the repro. I tried debugging but this vimscript-fu is beyond my abilities :)

A: First, you need to also have:

 Bundle 'plasticboy/vim-markdown'

B: Then you need to have a liquid front matter.

Now load a file that looks like this:


---
t:1
---
A
<!-- vim-markdown-toc GFM -->

- [Hello](#hello)

<!-- vim-markdown-toc -->
B
# Hello

Put your cursor on the line with text A, then :w Your file will be reformatted as follows (TOC now moved below the B):


---
t:1
---
A
B

<!-- vim-markdown-toc GFM -->

- [Hello](#hello)

<!-- vim-markdown-toc -->
# Hello

idvorkin avatar Feb 16 '21 17:02 idvorkin

Poke @mzlogin

idvorkin avatar Feb 16 '21 17:02 idvorkin

@idvorkin I'm sorry but I can't reproduce your phenomenon. Would you please provide more details, like your complete vim settings.

mac-os-x

mzlogin avatar Feb 21 '21 11:02 mzlogin

Thank you for the help! Simplified vimrc


syntax  on

 function! SetupPlugins()
 "  Vundle setup
     " Instructions @  https://github.com/VundleVim/Vundle.vim/blob/master/README.md
     " git clone https://github.com/VundleVim/Vundle.vim %USERPROFILE%/vimfiles/bundle/vundle
     " MAC - $ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
     filetype off
     set rtp+=~/vimfiles/bundle/Vundle
     set rtp+=~/.vim/bundle/Vundle.vim


     call vundle#begin()

     " Markdown stuff
     " *******************************
     Bundle 'mzlogin/vim-markdown-toc'
     " :GenTocGFM
     " :UpdateToc

     Bundle 'plasticboy/vim-markdown'
     " :TOC - Generate a toc sidebar
     " :VSize - Resize to 20
     " ]] Next Header
     " [[ Prev Header
     call vundle#end()            " required
 endfunc

 call SetupPlugins()

 filetype plugin indent on    " required

 let g:vim_markdown_follow_anchor = 1 " ge will jump to anchor (TBD: Map to C-]
 let g:vim_markdown_toc_autofit = 1 " Great for not wasting extra space
 let g:vim_markdown_frontmatter = 1
 set conceallevel=2
 let g:vim_markdown_new_list_item_indent = 0
 let g:vim_markdown_folding_level = 4
 let g:vmt_list_item_char='-'

 " Always enable softpencil

 "By default, swap out all instances in a line during substitutions
 set gdefault
 "
 " vim:foldmethod=indent:

idvorkin avatar Feb 21 '21 12:02 idvorkin

I also observed a 100% repro if I load the file from disk and then do the save before making any other changes. @mzlogin

idvorkin avatar Feb 21 '21 12:02 idvorkin

let g:vim_markdown_frontmatter = 1

If I remove this line, everything will work well. But I still don't know why.

mzlogin avatar Mar 05 '21 02:03 mzlogin

Thx. If it's helpful, a theory I had (though didn't test) was folding is interfering with the view computations

I wondered if a different approach would help. Like instead of erase the toc guards, leave the guards, delete toc and re-insert toc.

idvorkin avatar Mar 05 '21 03:03 idvorkin