atom / whitespace

Atom whitespace package
MIT License
94 stars 67 forks source link

Broken option "Keep Markdown Line Break Whitespace" #166

Closed claudiofantacci closed 7 years ago

claudiofantacci commented 7 years ago

Prerequisites

Description

Keep Markdown Line Break Whitespace does not work with the option Removing Trailing Whitespace, even though the documentation says that "[...]. Enable this option to keep this whitespace in Markdown files, even if other settings would remove it.".

Steps to Reproduce

  1. Enable both options
  2. Write two lines having the first with two trailing spaces (i.e. you want to break line)
  3. Save

Expected behavior: Trailing spaces should not be removed because of the option Keep Markdown Line Break Whitespace.

Actual behavior: Trailing spaces are removed.

Reproduces how often: Always. You have to disable Removing Trailing Whitespace or use system-scoped properties.

Versions

macOS 10.12.6

Atom : 1.21.1 Electron: 1.6.15 Chrome : 56.0.2924.87 Node : 7.4.0

apm 1.18.5 npm 3.10.10 node 6.9.5 x64 python 2.7.10 git 2.13.0

Ben3eeE commented 7 years ago

Thank you for the report!

I have a few questions to check if this is a duplicate of https://github.com/atom/whitespace/issues/137

claudiofantacci commented 7 years ago

Hi @Ben3eeE,

let's go in order.

Do you have the language-gfm package enabled?

It is disabled in my Atom settings (...and I was unaware of it!).
I made this tests:

Do you have the grammar of the file set to GitHub Markdown?

I guess that the answer is Yes. And I elaborate more your two questions with the following table.

Keep Markdown Line Break Whitespace always ON

Safe Mode language-markdown language-gfm Removing Trailing Whitespace Result
ON OFF OFF OFF Present
ON OFF OFF ON Trimmed
ON OFF ON OFF Present
ON OFF ON ON Present
OFF OFF OFF OFF Present
OFF OFF OFF ON Trimmed
OFF OFF ON OFF Present
OFF OFF ON ON Trimmed
OFF ON OFF OFF Present
OFF ON OFF ON Trimmed
OFF ON ON OFF Present
OFF ON ON ON Trimmed

IMHO, the bold-faced Results are wrong, but with different comment on each:

Ben3eeE commented 7 years ago

It is disabled in my Atom settings (...and I was unaware of it!).

Yes language-markdown disables language-gfm. I believe there is some setting for this in the language-markdown package

OFF | OFF | ON | ON this should always work

I agree however there might be some other package the interferes with the setting. Try this:

  1. Disable language-markdown
  2. Enable language-gfm
  3. Close any open markdown files
  4. Restart Atom
  5. Check if the setting works

This should force the Grammar to be set correctly.

OFF | ON | OFF | ON this may not be working because of incompatibility with 3rd party language-markdown

Yes.

OFF | ON | ON | ON this should work because language-gfm is enabled and should (right?) have some sort of precedence over language-markdown

No it doesn't have precedence over language-markdown. This is determined by the Grammar. If it's set to GitHub Markdown the setting should work. language-markdown has it's own scopes defined in the grammar which are not included by this setting.

And there is a bug report for this: https://github.com/atom/whitespace/issues/137

claudiofantacci commented 7 years ago

No it doesn't have precedence over language-markdown. This is determined by the Grammar. If it's set to GitHub Markdown the setting should work. language-markdown has it's own scopes defined in the grammar which are not included by this setting.

Ok, good to know this for the future.

I agree however there might be some other package the interferes with the setting. Try this:

Disable language-markdown Enable language-gfm Close any open markdown files Restart Atom Check if the setting works

It works! I'll keep this configuration then. The issue is related to language-markdown, I'll discuss this with them.

Thanks for the support!

Ben3eeE commented 7 years ago

Thanks for the support!

You're welcome :slightly_smiling_face:

evilmtv commented 6 years ago

@claudiofantacci Issue still persists, switching to language-gfm seems to be the only way. Did you manage to bring it up with language-markdown?

Ben3eeE commented 6 years ago

@evilmtv The issue on language-markdown is here https://github.com/burodepeper/language-markdown/issues/200. You may want to check there for updates :slightly_smiling_face:

samuraijane commented 5 years ago

For others who may read this in 2019 or later. I am using Atom 1.35.1. I had installed language-markdown (which disabled language-gfm). After removing language-markdown and re-enabling language-gfm, Atom was still removing the 2-space trailing whitespace in my .md files. The solution, as noted by @Ben3eeE, was to close the open tabs of the .md files and restart Atom. After doing this, the 2-space trailing whitespace persists in my .md files. Restarting Atom without closing the tabs had no effect. Be sure to close your tabs.