Skip to content

Commit

Permalink
fix fail to wrap down on last line
Browse files Browse the repository at this point in the history
  • Loading branch information
midnightsyntax committed Sep 11, 2017
1 parent 19dffd0 commit 05f1ff9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,16 @@ function handle(target: Wrap, prefix?: boolean, input?: boolean) {

case Wrap.Down: {

let nxtLine;
let nxtLineEmpty;
let nxtLineInd;
let nxtLine: vscode.TextLine;
let nxtLineEmpty: boolean;
let nxtLineInd: string;

if (!wrap.lastLine) {
nxtLine = wrap.doc.lineAt(wrap.line+1);
nxtLineEmpty = nxtLine.text.trim() == '' ? true : false;
nxtLineInd = nxtLine.text.substring(0, nxtLine.firstNonWhitespaceCharacterIndex);
} else {
nxtLineInd = "";
}

wrap.ind = vscode.workspace.getConfiguration("wrap-console-log")["autoFormat"] == true ? "" : wrap.ind;
Expand All @@ -104,7 +106,7 @@ function handle(target: Wrap, prefix?: boolean, input?: boolean) {
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((nxtLineInd.length > wrap.ind ? nxtLineInd : wrap.ind), wrap.txt));
"\n".concat((nxtLineInd.length > wrap.ind.length ? nxtLineInd : wrap.ind), wrap.txt));
}
})
}).then(() => {
Expand Down

0 comments on commit 05f1ff9

Please sign in to comment.