zhuochun / md-writer

✒️ Make Atom a better Markdown/AsciiDoc editor for writers and bloggers
https://atom.io/packages/markdown-writer
MIT License
341 stars 46 forks source link

TAB indent of list item stopped working #293

Open derekwsgray opened 5 years ago

derekwsgray commented 5 years ago

Describe the bug I upgraded Atom from 1.38.something to 1.40.1. After upgrading, the TAB key is just adding the spaces, but not indenting the bullet.

To Reproduce Steps to reproduce the behavior:

  1. Open a markdown file and start a list using a dash -, a space then type.
  2. Hit ENTER to go to the next line. A dash is correctly inserted for the next list item and the cursor is to the right of that by 1 space.
  3. hit TAB to indent the list item.
  4. 4 spaces are inserted after the dash, the dash has not moved over.

Expected behavior I expected the list item to indent as a whole, to the right, dash and all. For the past year I've used this on a daily basis - I could click in the middle of the line of a list item and hit tab and it would indent the whole thing. Now it's just inserting spaces with no recognition.

Screenshots

Additional context I tried uninstalling and re-installing the plugin but it made no difference.

aviatesk commented 5 years ago

I encountered this issue too, after updating this package to the latest version (v2.11.8). I confirmed v2.11.7 doesn't produce this issue, thus I suspect there is some regression in v2.11.8.

/cc @zhuochun hope you find it worth to be fixed ;)

zhuochun commented 5 years ago

There was one behavior change in version v2.11.8, where Tab indent only kick in when the indent will create a valid sublist.

From my own test on Atom v1.40.1 and Markdown Writer v2.11.8, on a blank Markdown file (_ is the cursor):

- Test
- _

Tab will indent one level:

- Test
  * _

Tab again will insert 2 spaces.

@derekwsgray @aviatesk maybe you can provide the full content of the Markdown file? or try the example I gave to spot the difference in expected behavior?

aviatesk commented 5 years ago

@zhuochun Thanks for getting me back !

I found markdown-write: indent-list-line doesn't work when an open editor's getTabLength() !== 2.

(On Atom v1.40.1, and markdown-writer@2.11.8)

zhuochun commented 5 years ago

@aviatesk Thanks. Now I can reproduce the behavior.

The quick immediate fix is change Package > Language Markdown > Tab Length to 2 first (this only applies to Markdown files).

I will need to revise whether to not use getTabLength.

aviatesk commented 5 years ago

@zhuochun are you willing to fix this ? If you're not, I may want to help you out if given some pointers.

derekwsgray commented 5 years ago

Confused why this would be tagged enhancement if it is a feature regression?

Also, I don't have the Package > Language Markdown even installed.

".source.md":
  editor:
    tabLength: 2

Had no effect either.

Installing language-markdown and changing the tab length setting resulted in even worse behaviour for me, adding even more tabs on top of the indent:

- This is a test of the lists.
    - This is a second items
    -       fjdkla
    -             fjkdlsa;
    -                   fdjkls;a 
derekwsgray commented 5 years ago

Ok, the workaround is to install language-markdown and just disable the markdown-writer keybindings, then I get the normal 4-space tab that I had originally and the correct list tabbing behaviour.

aviatesk commented 5 years ago

Obviously you can downgrade this package via apm install markdown-writer@2.11.7

or if you want to stick with language-gfm just set

".gfm.source":
  editor:
    tabLength: 2
aviatesk commented 5 years ago

Ok, the workaround is to install language-markdown and just disable the markdown-writer keybindings, then I get the normal 4-space tab that I had originally and the correct list tabbing behaviour.

This workaround just uses langauge-markdown's markdown: indent-list-item and then you can't use changing list prefix and the other fancy feature that markdown-writer provides.

derekwsgray commented 5 years ago

True, my workaround is heavy-handed. I'm a simple guy though and don't use those features :)

derekwsgray commented 5 years ago

(Downgrading the plugin means you have a blue "1 update" notification in the bottom right corner all the time - unless someone knows a plugin that then allows us to ignore updates for particular plugins...)

aviatesk commented 5 years ago

dirty solution:

~/.atom/styles.less

atom-workspace {
status-bar {
.package-updates-status-view {
display: none;
}
}
}
zhuochun commented 5 years ago

The latest change on latest Markdown Writer v2.11.9 should address the issue.

aviatesk commented 5 years ago

Thanks for the fix, and the command can be invoked with v2.11.9, but I found it still doesn't respect the tag length of an editor (it seems to always indent with 2 speces) ...

derekwsgray commented 5 years ago

Same here, it's back to 2-spaces.

zhuochun commented 5 years ago

The original change introduced in v2.11.8 is to follow https://spec.commonmark.org/0.29/#list-items

The most important thing to notice is that the position of the text after the list marker determines how much indentation is needed in subsequent blocks in the list item.

By spec, indented by 2 spaces is the expected behavior. Although indent by 4 spaces also work in parser.

aviatesk commented 5 years ago

Okay got it ! Feel free to close this issue then :)

I will move to use 2 spaces but thanks for the fix anyway.

michael-w-williams commented 5 years ago

Please consider adding a tablength setting to markdown-writer so I can set the tab/indent length to 4 spaces. Clearly the common mark and GFM spec allow 2 spaces. However, we live in a world where the markdown parser/processor determines what is gonna be rendered. For example, GitHub and Pandoc process 2 spaces. However the Python dudes seem to be strongly in the 4 spaces camp:

“each subsequent paragraph in a list item must be indented by either 4 spaces or one tab” (emphasis added). However, many implementations do not enforce this rule and allow less than 4 spaces of indentation. The implementers of Python-Markdown consider it a bug to not enforce this rule.

See: https://python-markdown.github.io/

Therefore, I am stuck with 4 spaces (which works everywhere). I can't use the plugin if 2 spaces is the only option. Thanks for your consideration.

bressain commented 4 years ago

Yeah, this seems broken for me as well. I use Atom almost exclusively as a Markdown editor so I have the line length defaulted to 4. I was surprised after updating that tabbing only went 2 spaces. Seems like this should respect those defaults.

Downgraded to 2.11.7 to get the behavior I want for now 🤷‍♂.

zhuochun commented 4 years ago

As I am went through https://python-markdown.github.io/ and https://daringfireball.net/projects/markdown/syntax#list

In examples provided in DaringFireball, the 1st level of list is * and 3 spaces. In this case, the 2nd level of list would start with 4 spaces, which align with commonmark spec.

*   Bird
    *   Level 2
*   Magic

Cross check on the plugin, it did not support extra spaces after * and need to be fixed.