Skip to content

using o and enter on code blocks deletes the line #143

Closed

Description

@m-fonseca

OS type:

  • Unix
  • Windows
  • Other ([SPECIFY])

Vim:

  • vim
  • neovim
  • Other ([SPECIFY])

Vim version:
NVIM v0.4.4

Using mkdx 602a784

Reproduce steps:

Use the following markdown file.

Test1
=====
 
This is a test
 
        indented code block
  1. Imediatly after indented code block press enter.

Expected:

The cursor goes to next line.

Actual:

The line is deleted 🤯 . Note: the same happens when pressing 'o' while the cursor is on indented code block line

I thought I had a conflict with all my mods, so I created a clean setup with no mods except this one, and a init.vim like below, and it still exhibits the problem.


" mkdx - markdown formating plugin {{{
let g:mkdx#settings     = { 'highlight': { 'enable': 1 },
                        \ 'enter': { 'shift': 1 },
                        \ 'links': { 'external': { 'enable': 0 } },
                        \ 'table': { 'align': { 'left':[], 'center':[],'right':[], 'default': 'left' } },
                        \ 'toc': { 'text': 'Table of Contents', 'update_on_write': 1 },
                        \ 'fold': { 'enable': 1 },
                        \ 'map': { 'prefix': 'm' } }
let g:polyglot_disabled = ['markdown'] " for vim-polyglot users, it loads Plasticboy's markdown


:let g:mkdx#settings.gf_on_steroids = 1

" }}}

Thanks!

Activity

  1. self-assigned this
    on Apr 7, 2021
  2. added
    bug:reportSomething does not work as intended / expected.
    on Apr 7, 2021
  3. SidOfc commented on Apr 7, 2021

    @SidOfc
    Owner

    Hello @m-fonseca, yeah this was another thing I overlooked, I naively thought most folks would just use fenced code blocks 😅

    Anyways, this would normally be quite tricky to properly detect since list items can also be at an indent level of 4 so I can't assume every line with indent of 4 will be an indented code block. To "guess" correctly I'm using a bit of help from syntax highlighting, essentially if the cursor line is a markdownCodeBlock (indented code block) or markdownCode (fenced code block) normal behavior will be applied.

    With normal I mean that pressing either enter / o will indent the next line as well, and if you press enter on that newly added empty line again it will de-indent.

    Let me know if this is working properly for you, feel free to reopen if the issue persists.

  4. m-fonseca commented on Apr 8, 2021

    @m-fonseca
    Author

    Seems to be working now. Thanks!

  5. m-fonseca commented on Apr 8, 2021

    @m-fonseca
    Author

    I found one other case where the o deletes the line, but I have to admit, it might not be valid markdown. Still it would preferable if it didn't delete lines 😉 .

    Test
    ====
    
    This is a *test
    
        testing
    

    do o on testing

  6. added a commit that references this issue on Apr 8, 2021
  7. SidOfc commented on Apr 8, 2021

    @SidOfc
    Owner

    @m-fonseca this one is also fixed now. It is not exactly invalid markdown but the *test is seen as an unclosed markdownItalic tag.

  8. m-fonseca commented on Apr 8, 2021

    @m-fonseca
    Author

    Verified. Thanks for the fix!

  9. lclrc commented on Jan 16, 2022

    @lclrc

    Compatible with Pandoc? pandoc and it's syntax defined some highlight name, such as pandocDelimitedCodeBlock.

    Temporarily, I changed:

    if (index(cursor_line_hl, 'markdownCodeBlock' ) > -1 || index(cursor_line_hl, 'markdownCode') > -1)

    To:

    if (index(cursor_line_hl, 'pandocDelimitedCodeBlock') > -1 || index(cursor_line_hl, 'markdownCodeBlock' ) > -1 || index(cursor_line_hl, 'markdownCode') > -1)

    Otherwise, using o or <enter> on indent code blocks will delete the line

  10. SidOfc commented on Jan 16, 2022

    @SidOfc
    Owner

    Hello @lclrc,

    Cheers for the example code which shows clearly what you want to achieve, and if I understand correctly, it also fixes your issue as well right?

    If this is the case, would you mind opening a PR with this fix?

    Additionally, I appreciate the effort of you looking for similar issues before just opening a new one 👍. That said, this would have been a solid issue by itself since this is specifically about vim-pandoc and it causes the problem described in this issue :)

    Thank you for your time and contribution to mkdx.vim! 🚀

  11. lclrc commented on Jan 26, 2022

    @lclrc

    @SidOfc Sorry for my late reply! Github did not notify me. :(

    and if I understand correctly, it also fixes your issue as well right?

    yes, but I think the example code is "hard code", maybe I need to test its stability and functionality. And then I will open a PR. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:reportSomething does not work as intended / expected.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions