Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Add check for Files>EOL ==="auto" and set it to "\n" #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

PHeonix25
Copy link

In the spirit of "be the change you want to see", I humbly propose this short solution that fixes issue #65.

FWIW - I haven't tested this conclusively, but it worked for me and saved me from having to change system-wide settings.

Copy link

@ctsstc ctsstc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

As for tests there doesn't seem to currently be any implemented on this repository yet.

@ctsstc
Copy link

ctsstc commented Jan 5, 2019

Using require('os').EOL should get you the current OS EOL.

@PHeonix25
Copy link
Author

PHeonix25 commented Jan 7, 2019

@ctsstc - updated as requested.
Sorry for the formatting fixes in package.json - it introduces some confusion as to what is an actual change, and what is a layout update. 😞

Also, I don't know the ramifications of changing the "module resolution" to "node", but I had to do that to get it to compile for me, so I've included it in the commit.

// See https://github.com/AlanWalk/markdown-toc/issues/65
lineEnding = "\n";
lineEnding = require('os').EOL;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably change this to an import at the top of the file

import { EOL } from 'os';

This also allows for a change on line 249 in the insertAnchor method where it builds the text variable.

This

let text = [ '<a id="markdown-', name, '" name="', name, '"></a>\n' ];

Can be changed to

let text = [ '<a id="markdown-', name, '" name="', name, '"></a>', EOL ];

@ctsstc
Copy link

ctsstc commented Jan 7, 2019

I too wasn't sure if we'd have the node namespace available for the extension, so I'm glad you dug into that, but I don't know much about it myself either.

@surendra-y
Copy link

surendra-y commented Feb 18, 2019

Hey guys,

It would be great if we could have this merged and part of the latest release.
I really like this extension.

Cheers!!

@ratbeard
Copy link

Please merge and deploy this!!!!!!!!!!!!!!!!!

@ratbeard
Copy link

Nevermind I just installed https://github.com/yzhang-gh/vscode-markdown instead!!!!!!

@huntertran
Copy link

I managed to fix all the tslints (which is required to build new version) and merge the pull request.
The new version of this extension can be found at this marketplace link
Source code

If you found any issue related to code refactoring, please create new issue (and pull request if you can fix it). Many thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants