diff --git a/CHANGELOG.md b/CHANGELOG.md index f4e885a..44d8b69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,17 +2,29 @@ # CHANGELOG +## 1.3.3 +##### 2017-09-11 + +### Changed + +- `Wrap down` will now, if next line exists: + - Keep same indent as **current line** if next line indent is shorter. + - Use the same indent as **next line** if next line indent is longer. + +--- + + ## 1.3.2 ##### 2017-09-10 ### Changed -- `Wrap down` will now, if next line is empty, insert without creating a new line +- `Wrap down` will now, if next line exists but is empty, insert without creating a new line ### Fixed - Indent break on wrap down -- Wrap down fail to execute if no line exist below +- `Wrap down` fail to execute if no line exist below - Unhandled promise rejections --- diff --git a/package.json b/package.json index 740337a..c4471b9 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "git", "url": "https://github.com/midnightsyntax/vscode-wrap-console-log" }, - "version": "1.3.2", + "version": "1.3.3", "publisher": "midnightsyntax", "icon": "images/icon.png", "engines": { diff --git a/src/extension.ts b/src/extension.ts index dc090b4..1954dfb 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -87,10 +87,12 @@ function handle(target: Wrap, prefix?: boolean, input?: boolean) { let nxtLine; let nxtLineEmpty; + let nxtLineInd; if (!wrap.lastLine) { nxtLine = wrap.doc.lineAt(wrap.line+1); nxtLineEmpty = nxtLine.text.trim() == '' ? true : false; + nxtLineInd = nxtLine.text.substring(0, nxtLine.firstNonWhitespaceCharacterIndex); } wrap.ind = vscode.workspace.getConfiguration("wrap-console-log")["autoFormat"] == true ? "" : wrap.ind; @@ -101,7 +103,8 @@ function handle(target: Wrap, prefix?: boolean, input?: boolean) { if (nxtLineEmpty) { e.replace(new vscode.Position(nxtLine.lineNumber, 0), wrap.ind.concat(wrap.txt)); } else { - e.insert(new vscode.Position(wrap.line, wrap.doc.lineAt(wrap.line).range.end.character), "\n".concat(wrap.ind, wrap.txt)); + e.insert(new vscode.Position(wrap.line, wrap.doc.lineAt(wrap.line).range.end.character), + "\n".concat((nxtLineInd.length > wrap.ind ? nxtLineInd : wrap.ind), wrap.txt)); } }) }).then(() => {