alanwalk / markdown-toc

MarkdownTOC(Table Of Contents) Plugin for Visual Studio Code.
MIT License
141 stars 111 forks source link

fix vscode 1.29.0's breaking feature: eol=auto #66

Closed gfx closed 4 years ago

gfx commented 5 years ago

Fix https://github.com/AlanWalk/markdown-toc/issues/65

workaround before this PR

Set files.eol to "\n" or "\r\n" in vscode settings. auto is a new feture introduced in v1.29.0

3ygun commented 5 years ago

@gfx wanted to link the original VSCode changes

Don't know if you can call one of those getEol methods and/or import OS and do the check yourself

ctsstc commented 5 years ago

Now seeing that #72 looks to be a duplicate of this, although a slightly different implementation.

ctsstc commented 5 years ago

From https://github.com/AlanWalk/markdown-toc/pull/72#pullrequestreview-189579058

Seems that the VSCode snippet builder builds snippets the same way via an array and then joins them together. It seems they are only using '\n' for all cases. Maybe the secret is to just do \n and post processing will handle the rest.

VSCode's snippet building: https://github.com/Microsoft/vscode/blob/82863aac3b43b9559057295afcf5f99edd9f5f22/src/vs/workbench/parts/snippets/electron-browser/snippetsFile.ts#L227

VSCode's snippet implementation example: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_global-snippets

I dug around in the VSCode Extension API and couldn't really find anything about determining the OS EOL's value.

Looks like we should be able to use require('os').EOL though.

JedBartlett commented 5 years ago

Should this be closed then to let #72 go through?

gfx commented 4 years ago

Closed in favor of https://github.com/AlanWalk/markdown-toc/pull/80