diff --git a/package.json b/package.json index a7f22d4..5151c7d 100644 --- a/package.json +++ b/package.json @@ -35,22 +35,23 @@ "main": "./out/src/extension", "contributes": { "commands": [ - { - "command": "extension.updateMarkdownToc", - "title": "Markdown TOC: Insert/Update" - }, - { - "command": "extension.deleteMarkdownToc", - "title": "Markdown TOC: Delete" - }, - { - "command": "extension.updateMarkdownSections", - "title": "Markdown Sections: Insert/Update" - }, - { - "command": "extension.deleteMarkdownSections", - "title": "Markdown Sections: Delete" - }], + { + "command": "extension.updateMarkdownToc", + "title": "Markdown TOC: Insert/Update" + }, + { + "command": "extension.deleteMarkdownToc", + "title": "Markdown TOC: Delete" + }, + { + "command": "extension.updateMarkdownSections", + "title": "Markdown Sections: Insert/Update" + }, + { + "command": "extension.deleteMarkdownSections", + "title": "Markdown Sections: Delete" + } + ], "menus": { "editor/context": [ { @@ -71,7 +72,7 @@ } ] }, - "keybindings":[ + "keybindings": [ { "command": "extension.updateMarkdownToc", "key": "ctrl+m t" @@ -119,12 +120,12 @@ "type": "string", "default": "github.com", "description": "anchor mode.", - "enum": [ - "github.com", - "bitbucket.org", - "ghost.org", + "enum": [ + "github.com", + "bitbucket.org", + "ghost.org", "gitlab.com" - ] + ] } } } @@ -135,6 +136,7 @@ "postinstall": "node ./node_modules/vscode/bin/install" }, "dependencies": { + "@types/node": "^10.12.18", "anchor-markdown-header": "^0.5.7" }, "devDependencies": { diff --git a/src/extension.ts b/src/extension.ts index 03a12bc..813606f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -267,7 +267,13 @@ class MarkdownTocTools { let lineEnding = workspace.getConfiguration("files").get("eol"); let tabSize = workspace.getConfiguration("[markdown]")["editor.tabSize"]; let insertSpaces = workspace.getConfiguration("[markdown]")["editor.insertSpaces"]; - + + if(lineEnding === undefined || lineEnding === null || lineEnding === "auto") { + // Use OS default line-endings where `Files > EOL` was set to the string value "auto". + // "eol=auto" was introduced in VSCode update 1.29.0. + // See https://github.com/AlanWalk/markdown-toc/issues/65 + lineEnding = require('os').EOL; + } if(tabSize === undefined || tabSize === null) { tabSize = workspace.getConfiguration("editor").get("tabSize"); } diff --git a/tsconfig.json b/tsconfig.json index e5187e7..b9e5ded 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,11 @@ "outDir": "out", "noLib": true, "sourceMap": true, - "rootDir": "." + "rootDir": ".", + "moduleResolution": "node", + "types": [ + "node" + ] }, "exclude": [ "node_modules"