Skip to content
This repository was archived by the owner on Nov 28, 2018. It is now read-only.

Commit 499aa9d

Browse files
dellis23chrisdone
authored andcommitted
Auto-indent to previous line indent (#39)
1 parent c394fd2 commit 499aa9d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

jquery.console.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,12 @@
438438
};
439439

440440
function newLine() {
441-
promptText += "\n";
442-
moveColumn(1);
441+
var lines = promptText.split("\n");
442+
var last_line = lines.slice(-1)[0];
443+
var spaces = last_line.match(/^(\s*)/g)[0];
444+
var new_line = "\n" + spaces;
445+
promptText += new_line;
446+
moveColumn(new_line.length);
443447
updatePromptDisplay();
444448
};
445449

0 commit comments

Comments
 (0)