Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Whitespace stripped from markdown despite settings, doesn't work with text.md scope #185

Open
1 task done
thoschworks opened this issue Dec 2, 2018 · 19 comments
Open
1 task done

Comments

@thoschworks
Copy link

thoschworks commented Dec 2, 2018

Edit by @rsese to describe the larger issue

As mentioned in #185 (comment):

It's not as much that language-markdown doesn't respect the setting, but whitespace should now also work within the text.md scope.

I believe #177 was supposed to add this functionality so that the whitespace package worked with the text.md scope but as mentioned in #185 (comment) (the author of #177), it looks like it may not have done what was intended.

The result is that if you use language-markdown (as in this report), the whitespace package will still strip trailing whitespace on save in Markdown files even if you have Keep Markdown Line Break Whitespace enabled.


Prerequisites

Description

Whitespace is stripping trailing whitespaces in markdown files despited the settings.

Edit by @rsese: not reproducible in safe mode because it reproduces when you install and use https://atom.io/packages/language-markdown

Steps to Reproduce

  1. Edit a README.md for a project
  2. Put two whitespaces at end of line to indicate a line break.
  3. Save the file.

Expected behavior: The whitespace at the end of the line are ignored and and not deleted.

Actual behavior: The whitespaces are deleted. (The trailing whitespaces in the current line are ignored.) If the option "Remove Trailing Whitespace" or the package Whitespace is deactivated, the whitespaces remain.

Reproduces how often: 100.0000000%

Versions

Atom : 1.33.0
Electron: 2.0.11
Chrome : 61.0.3163.100
Node : 8.9.3

Whitespace: 0.37.7

OS: Mac OS Mohave 10.14.1

Additional Information

I can not reproduce the issue running Atom on Debian (Bunsen Labs).

@rsese
Copy link

rsese commented Dec 4, 2018

Thanks for the report - I'm unable to reproduce with 1.33.0 on macOS 10.12.6. Can you share your settings for Ignore Whitespace On Current Line and Keep Markdown Line Break Whitespace as well?

@thoschworks
Copy link
Author

Can you share your settings for Ignore Whitespace On Current Line and Keep Markdown Line Break Whitespace as well?

Both are activated.

@rsese
Copy link

rsese commented Dec 5, 2018

Hmm, I wonder if there's some setting/config somewhere causing the issue? If you temporarily reset to factory defaults, can you still reproduce?

@thoschworks
Copy link
Author

I have no access to the machine for the next days. Stay tuned…

@thoschworks
Copy link
Author

After resetting to the factory settings, the problem was solved until I reinstalled the package language-markdown. (On the linux machine is not installed…)

I will report a bug for language-markdown.

@thoschworks
Copy link
Author

After resetting to the factory settings, the problem was solved until I reinstalled the package language-markdown. (On the linux machine is not installed…)

I will report a bug for language-markdown.

Or perhaps it's the combination of language-markdown and whitespace: language-markdown changes an attribute and whitespace can not recognize the source as markdown?

@rsese
Copy link

rsese commented Dec 11, 2018

the problem was solved until I reinstalled the package language-markdown. (

There's an existing issue for this on that package repository:

burodepeper/language-markdown#200

Looks like it was closed as resolved in #177 and that change is available in 1.33.0.

@burodepeper 👋 - am I misunderstanding #177? It seems like language-markdown should now respect whitespace's Keep Markdown Line Break Whitespace setting after your change?

@burodepeper
Copy link
Contributor

@rsese It's not as much that language-markdown doesn't respect the setting, but whitespace should now also work within the text.md scope. I can't remember to what extend I've tested it. Maybe this can be added to this package's spec?

@thoschworks
Copy link
Author

@rsese It's not as much that language-markdown doesn't respect the setting, but whitespace should now also work within the text.md scope. I can't remember to what extend I've tested it. Maybe this can be added to this package's spec?

This supports my assumtion, that there is a problem with combination of whitespace and language-markdown.

After adding

".text.md":
    whitespace:
    removeTrailingWhitespace: false

to my config.cson, the problem is solved.

I agree with @burodepeper that whitespace should also respect the scope text.md as markdown file.

burodepeper added a commit to burodepeper/whitespace that referenced this issue Dec 19, 2018
I made a mistake in atom#177.

For whatever reason, I wrote a quick patch in my browser, and obviously, this code would never yield anything useful, _because it is just silly javascript_. The discussion in atom#185 made me verify my patch. This new patch should actually do something, while I have to admit that I've only verified it via Chrome's console. My test below seems valid enough.

```js
const markdownGrammars = ['source.gfm', 'text.md']

let grammarScopeName = 'text.md'
markdownGrammars.includes(grammarScopeName) // true

grammarScopeName = 'source.js'
markdownGrammars.includes(grammarScopeName) // false
```
@burodepeper
Copy link
Contributor

I found an issue in my PR in #177 and I've submitted a new PR #186 to fix it. I wrote silly Javascript, I take the blame.

@rsese
Copy link

rsese commented Dec 19, 2018

Just circling back to this, thanks @burodepeper! I'll edit this issue body today so it's clear the problem is that the whitespace package isn't working with the text.md scope as it was meant to after #177.

@rsese rsese added the triaged label Dec 19, 2018
@rsese rsese changed the title Whitespace stripped from markdown despite settings, again Whitespace stripped from markdown despite settings, doesn't work with text.md scope Dec 19, 2018
@ivanpu
Copy link

ivanpu commented Mar 17, 2019

Um... I made a PR for this, but it was attached to the wrong repository... is it possible to migrate it, or should I create a new one from scratch?

@burodepeper
Copy link
Contributor

I haven't had time to add tests to my previous PR. If you find time to do it for yours, feel free to do so, then I'll remove my PR.

@ivanpu
Copy link

ivanpu commented Mar 19, 2019

I don't know how to add tests, and couldn't find how to test manually on my machine (couldn't find this package files within atom directories). Is there some documentation for this?

@rsese
Copy link

rsese commented Mar 19, 2019

Our documentation on writing tests is here (it covers running tests as well):

https://flight-manual.atom.io/hacking-atom/sections/writing-specs/

If you need help writing automated tests for Atom, check out Discuss, the official Atom and Electron message board or join the Atom Slack team. There are a bunch of helpful community members that should be willing to point you in the right direction (I'm not an engineer so can't help you myself unfortunately).

@thoschworks

This comment has been minimized.

@rsese

This comment has been minimized.

@thoschworks

This comment has been minimized.

@ivanpu
Copy link

ivanpu commented Apr 18, 2019

@rsese Thanks, will look at it, hopefully soon - I'm too busy these days with work.

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

4 participants