-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
repl: fix crash with large buffer tab completion #13817
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 1 commit
a59ca52
c08093e
402070d
59649f3
876ab6e
11db662
573e252
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -702,7 +702,7 @@ function mayBeLargeObject(obj) { | |
| function filteredOwnPropertyNames(obj) { | ||
| if (!obj) return []; | ||
| if (mayBeLargeObject(obj) && obj.length > 1e6) { | ||
| process.stdout.write('\r\n'); | ||
| this._writeToOutput('\r\n'); | ||
| process.emitWarning( | ||
| 'Instance is too large that the completion may missing ' + | ||
|
Contributor
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. I feel like "so" might be better than "that" here (but I'm not a native speaker). |
||
| 'some customized properties.', | ||
|
Contributor
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. And "custom" might be better than "customized" here. (As for me, "customized" implies properties that have been changed, not necessarily added.) |
||
|
|
@@ -756,6 +756,7 @@ function complete(line, callback) { | |
| } | ||
| } | ||
|
|
||
| var self = this; | ||
|
Member
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. would prefer not to introduce a new
Contributor
Author
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. But I need use
Contributor
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. Can you please use an arrow function so that you don't need the |
||
| var completions; | ||
|
|
||
| // list of completion lists, one for each inheritance "level" | ||
|
|
@@ -867,9 +868,11 @@ function complete(line, callback) { | |
| if (this.useGlobal || vm.isContext(this.context)) { | ||
| var contextProto = this.context; | ||
| while (contextProto = Object.getPrototypeOf(contextProto)) { | ||
| completionGroups.push(filteredOwnPropertyNames(contextProto)); | ||
| completionGroups.push( | ||
| filteredOwnPropertyNames.call(this, contextProto)); | ||
| } | ||
| completionGroups.push(filteredOwnPropertyNames(this.context)); | ||
| completionGroups.push( | ||
| filteredOwnPropertyNames.call(this, this.context)); | ||
| addStandardGlobals(completionGroups, filter); | ||
| completionGroupsLoaded(); | ||
| } else { | ||
|
|
@@ -895,7 +898,7 @@ function complete(line, callback) { | |
| if (obj != null) { | ||
| if (typeof obj === 'object' || typeof obj === 'function') { | ||
| try { | ||
| memberGroups.push(filteredOwnPropertyNames(obj)); | ||
| memberGroups.push(filteredOwnPropertyNames.call(self, obj)); | ||
| } catch (ex) { | ||
| // Probably a Proxy object without `getOwnPropertyNames` trap. | ||
| // We simply ignore it here, as we don't want to break the | ||
|
|
@@ -913,7 +916,7 @@ function complete(line, callback) { | |
| p = obj.constructor ? obj.constructor.prototype : null; | ||
| } | ||
| while (p !== null) { | ||
| memberGroups.push(filteredOwnPropertyNames(p)); | ||
| memberGroups.push(filteredOwnPropertyNames.call(self, p)); | ||
| p = Object.getPrototypeOf(p); | ||
| // Circular refs possible? Let's guard against that. | ||
| sentinel--; | ||
|
|
||
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.
Can you use a constant for
1e6likeconst ARRAY_LENGTH_THRESHOLD?