diff --git a/CHANGELOG.md b/CHANGELOG.md index 488567a..ec80874 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,21 @@ # CHANGELOG +--- + +## 1.6.0 +##### 2018-01-15 + +### Added +- Custom wrap text! +- New config settings `.wrapText` + +Specify the text to wrap with with the new setting `.wrapText`. +The default value of this setting is `console.log($txt);` where `$txt` specifies where the variable/text should be inserted. If the value of `.wrapText` does not include `$txt` vscode will warn you. Make sure you specify `$txt` ONE time if you change this setting. + +--- + + ## 1.5.0 ##### 2018-01-12 diff --git a/README.md b/README.md index bbc65b0..1b1624c 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ Also, you are free to rebind all keyboard shortcuts as you want in your workspac * `Alt+Shift+W` + `W` +##### OBS: If the string to log contains spaces you need to select the whole string + --- ### Log on current line diff --git a/package.json b/package.json index 596797a..935dfd2 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "git", "url": "https://github.com/midnightsyntax/vscode-wrap-console-log" }, - "version": "1.5.3", + "version": "1.6.0", "publisher": "midnightsyntax", "icon": "images/icon.png", "engines": { @@ -84,6 +84,13 @@ "title": "Always log with the wrapped word as prefix.", "description": "If true ALL wraps will log with the selected word as prefix.", "default": false + }, + "wrap-console-log.wrapText": { + "title": "The text to wrap with.", + "description": "Use $text to specify where in the string your variable/text should be placed.", + "type": "string", + "default": "console.log($txt);", + "pattern": "\\$txt" } } }, diff --git a/src/extension.ts b/src/extension.ts index 1db1439..48661be 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -54,27 +54,31 @@ function handle(target: Wrap, prefix?: boolean, input?: boolean, formatAs?: Form let txt = doc.getText(ran); let idx = doc.lineAt(lineNumber).firstNonWhitespaceCharacterIndex; let ind = doc.lineAt(lineNumber).text.substring(0, idx); - let wrapData = { txt: undefined, doc: doc, ran: ran, idx: idx, ind: ind, line: lineNumber, sel: sel, lastLine: doc.lineCount-1 == lineNumber } ; + let wrapData = { txt: getSetting('wrapText'), doc: doc, ran: ran, idx: idx, ind: ind, line: lineNumber, sel: sel, lastLine: doc.lineCount-1 == lineNumber } ; if (prefix || getSetting("alwaysUsePrefix")) { if (getSetting("alwaysInputBoxOnPrefix") == true || input) { vscode.window.showInputBox({placeHolder: 'Prefix', value: txt, prompt: 'Use text from input box as prefix'}).then((val) => { if (val != undefined) { - wrapData.txt = "console.log('".concat(val.trim(), "', ", txt ,");"); + //wrapData.txt = "console.log('".concat(val.trim(), "', ", txt ,");"); + wrapData.txt = wrapData.txt.replace('$txt', val); resolve(wrapData) } }) } else { - wrapData.txt = "console.log('".concat(txt, "', ", txt ,");"); + // wrapData.txt = "console.log('".concat(txt, "', ", txt ,");"); + wrapData.txt = wrapData.txt.replace('$txt', txt); resolve(wrapData) } } else { switch (formatAs) { case FormatAs.String: - wrapData.txt = "console.log('".concat(txt, "');"); + // wrapData.txt = "console.log('".concat(txt, "');"); + wrapData.txt = wrapData.txt.replace('$txt', "'".concat(txt, "'")); break; default: - wrapData.txt = "console.log(".concat(txt, ");"); + // wrapData.txt = "console.log(".concat(txt, ");"); + wrapData.txt = wrapData.txt.replace('$txt', txt); break; }