Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

TAB indent of list item stopped working #293

Open
derekwsgray opened this issue Sep 13, 2019 · 20 comments
Open

TAB indent of list item stopped working #293

derekwsgray opened this issue Sep 13, 2019 · 20 comments

Comments

@derekwsgray
Copy link

derekwsgray commented Sep 13, 2019

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
Copy link

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
Copy link
Owner

zhuochun commented Sep 15, 2019

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
Copy link

@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
Copy link
Owner

@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
Copy link

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

@derekwsgray
Copy link
Author

derekwsgray commented Sep 16, 2019

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
Copy link
Author

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
Copy link

aviatesk commented Sep 16, 2019

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
Copy link

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
Copy link
Author

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

@derekwsgray
Copy link
Author

(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
Copy link

aviatesk commented Sep 16, 2019

dirty solution:

~/.atom/styles.less

atom-workspace {
  status-bar {
    .package-updates-status-view {
      display: none;
    }
  }
}

@zhuochun
Copy link
Owner

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

@aviatesk
Copy link

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
Copy link
Author

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

@zhuochun
Copy link
Owner

zhuochun commented Sep 18, 2019

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
Copy link

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
Copy link

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
Copy link

bressain commented Nov 9, 2019

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
Copy link
Owner

zhuochun commented Mar 25, 2020

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.

@zhuochun zhuochun added the bug label Mar 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants