-
-
Couldn't load subscription status.
- Fork 33.6k
repl: Auto alignment for .editor mode #8241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ function Interface(input, output, completer, terminal) { | |
|
|
||
| this._sawReturn = false; | ||
| this.isCompletionEnabled = true; | ||
| this._sawKeyPress = false; | ||
| this._previousKey = null; | ||
|
|
||
| EventEmitter.call(this); | ||
|
|
@@ -247,6 +248,9 @@ Interface.prototype._addHistory = function() { | |
| // if the history is disabled then return the line | ||
| if (this.historySize === 0) return this.line; | ||
|
|
||
| // if the trimmed line is empty then return the line | ||
| if (this.line.trim().length === 0) return this.line; | ||
|
|
||
| if (this.history.length === 0 || this.history[0] !== this.line) { | ||
| this.history.unshift(this.line); | ||
|
|
||
|
|
@@ -947,6 +951,10 @@ function emitKeypressEvents(stream, iface) { | |
| if (r) { | ||
| clearTimeout(timeoutId); | ||
|
|
||
| if (iface) { | ||
| iface._sawKeyPress = r.length === 1; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this guarding against pasted code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
| } | ||
|
|
||
| for (var i = 0; i < r.length; i++) { | ||
| if (r[i] === '\t' && typeof r[i + 1] === 'string' && iface) { | ||
| iface.isCompletionEnabled = false; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make sure I understand, the changes here are technically independent from the rest of the changes, right? Like, it’s only in order not to clobber the history with whitespace-only lines that come from editor mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Incorporated test to ensure that whitespace-only lines are not added in history.