From 19dffd097fec44e0275c939ff3f3c92a76ea5864 Mon Sep 17 00:00:00 2001 From: midnightsyntax Date: Mon, 11 Sep 2017 19:12:39 +0200 Subject: [PATCH] change wrap down indent update CHANGELOG --- CHANGELOG.md | 16 ++++++++++++++-- package.json | 2 +- src/extension.ts | 5 ++++- 3 files changed, 19 insertions(+), 4 deletions(-) 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(() => {