SidOfc / mkdx

A vim plugin that adds some nice extra's for working with markdown documents

Home Page:https://www.vim.org/scripts/script.php?script_id=5620

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inserting list items

samarulmeu opened this issue Β· comments

There is a bug in creating a new items for both types of list (bullet and ordered). If you are at the end of the line and you press enter a new item is created, but if you are inside a line and press enter the remaining characters/words do not make a new item list.

Example:

- Something new or old.
            ^

I get

- Something
new or old

instead of

- Something
- new or old

Hmmn, actually is this a bug?

When checking the example on the documentation page, it makes no mention of this being an actual feature, also :h mkdx-function-enter-handler makes no mention of this behavior being supported.

If you did see a mention of this somewhere, can you point me to the place where you found it?

I do recall adding some code to the enter-handler to prevent it from adding list markers when pressing enter and not being at the end of the line though. I do not know anymore why exactly it was done.

I guess you would like to propose some new behavior here, the enter handler is a really complex function already though, and making changes there is like trying to step through a minefield πŸ˜…

Alternatively, isn't it easier to d$, followed by an o and pasting from there?

Actually I did not search the documentation. I just thought it will be normal to have the same behavior in creating a new list item by splitting a line.

To solve it I do just insert and - , but I thought that it is nice to have it automaticaly added. Not to mention the mess in the ordered list that does not get properly updated.

Makes sense indeed, this is something that word will happily do for you as well, but please do mind that unsupported behavior isn't a bug but rather a feature request :)

When I think of the word bug I immediately jump to "some existing functionality is broken" πŸ˜…

As for this request, I'll mark it as a feature request and see what I can do, it could be easier than thought, but could also be a nightmare to implement. Like I mentioned in the other reopened issue, it may take some time here as well.

Any case it's good feedback, cheers as usual πŸ‘

Please take your time. There is no hurry. I know that you make this in your free time and it amazing that you are offering such a nice plugin.

My logic in considering this as a bug was that "splitting" a line in an ordered/bullet list is not different than just adding a new empty one and I thought it makes sense to have the same behavior (adding a bullet or a number to the line empty or not, in my case).

I can understand the reasoning behind you thinking this being a bug because it doesn't seem like a separate use-case indeed. In this case though, checking the docs and seeing if it is supposed to work will make it clear if something is actively implemented and not working, or if it should be a new feature.

To me it seemed a bit quick to jump to the conclusion of marking it as a bug without checking the docs, I put a lot of effort into writing those to make sense as well and it only takes a few clicks to find the right documentation for any feature when you're in doubt :)

Point well taken though, but as a feature request rather than a bug πŸ‘Œ

Hmmn @samarulmeu I did indeed write tests to check explicitly that it would not do what you showed, but, after disabling the check to make sure enter is pressed at the end of the line, I see proper results one would expect when pressing enter in the middle.

My initial reasoning for this is beyond me since it has been quite a while since I initially wrote this functionality, but I believe always allowing it will actually not break anything πŸ€”

All other tests pass as well so I think I can safely enable this functionality, I'll update the tests to support this new behavior, you might see this land sooner than expected.

Can you update mkdx and check to see if this is indeed the desired behavior?

Thank you so much! That is just perfect! And I promise that I will not bother you this week as you've mentioned you have work to do.

And to clarify --- it was strange for me that this was not supported as I saw it as part of the list auto-formatting, that's why the bug thing.

Have a great evening!

I'm closing this now.

Haha I understand, it beats me why it worked that way but I think it will just be more useful now.

Feel free to open issues is you find em, if I can't process them they will remain open for a bit longer is all :) This one happened to be way easier to fix than I imagined (I went through some nightmares in the past with the enter handler hehe) so that was a nice twist :)

You have a great evening too! πŸ‘ πŸ‘‹