{"action":"created","comment":{"url":"https://api.github.com/repos/nodejs/node/pulls/comments/240005327","pull_request_review_id":182944382,"id":240005327,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MDAwNTMyNw==","diff_hunk":"@@ -500,8 +514,49 @@ Interface.prototype._insertString = function(c) {\n     // a hack to get the line refreshed if it's needed\n     this._moveCursor(0);\n   }\n+\n+  searchHistory.call(this);\n };\n \n+function appendSearchResult(result) {\n+  this.previewResult = result !== '' ?\n+    `\\u001b[90m // ${result}\\u001b[39m` : '';\n+\n+  // Cursor to left edge.\n+  cursorTo(this.output, 0);\n+  clearScreenDown(this.output);\n+\n+  this.output.write(this.reverseSearchPrompt + this.line + this.previewResult);\n+  // now move back the cursor to the original position\n+  cursorTo(this.output, this.cursor + this.reverseSearchPrompt.length);\n+}\n+\n+function searchHistory() {\n+\n+  const searchFor = (array, text) => {\n+    const result = [];\n+    for (var i = 0; i < array.length; i++)\n+      if (text.trim() !== '' && array[i].includes(text))\n+        result.push(array[i]);\n+    return result;","path":"lib/readline.js","position":65,"original_position":65,"commit_id":"35ab75ce0b22ac059b713bc20779f1bbd7410c69","original_commit_id":"35ab75ce0b22ac059b713bc20779f1bbd7410c69","user":{"login":"BridgeAR","id":8822573,"node_id":"MDQ6VXNlcjg4MjI1NzM=","avatar_url":"https://avatars2.githubusercontent.com/u/8822573?v=4","gravatar_id":"","url":"https://api.github.com/users/BridgeAR","html_url":"https://github.com/BridgeAR","followers_url":"https://api.github.com/users/BridgeAR/followers","following_url":"https://api.github.com/users/BridgeAR/following{/other_user}","gists_url":"https://api.github.com/users/BridgeAR/gists{/gist_id}","starred_url":"https://api.github.com/users/BridgeAR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BridgeAR/subscriptions","organizations_url":"https://api.github.com/users/BridgeAR/orgs","repos_url":"https://api.github.com/users/BridgeAR/repos","events_url":"https://api.github.com/users/BridgeAR/events{/privacy}","received_events_url":"https://api.github.com/users/BridgeAR/received_events","type":"User","site_admin":false},"body":"As a suggestion: I would not search the whole history each time but only search until the first match and continue searching from that index if the user wants a different entry.","created_at":"2018-12-08T13:42:22Z","updated_at":"2018-12-08T13:56:36Z","html_url":"https://github.com/nodejs/node/pull/24335#discussion_r240005327","pull_request_url":"https://api.github.com/repos/nodejs/node/pulls/24335","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments/240005327"},"html":{"href":"https://github.com/nodejs/node/pull/24335#discussion_r240005327"},"pull_request":{"href":"https://api.github.com/repos/nodejs/node/pulls/24335"}}},"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/24335","id":230413452,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMwNDEzNDUy","html_url":"https://github.com/nodejs/node/pull/24335","diff_url":"https://github.com/nodejs/node/pull/24335.diff","patch_url":"https://github.com/nodejs/node/pull/24335.patch","issue_url":"https://api.github.com/repos/nodejs/node/issues/24335","number":24335,"state":"open","locked":false,"title":"repl: add reverse search to repl","user":{"login":"antsmartian","id":1241511,"node_id":"MDQ6VXNlcjEyNDE1MTE=","avatar_url":"https://avatars2.githubusercontent.com/u/1241511?v=4","gravatar_id":"","url":"https://api.github.com/users/antsmartian","html_url":"https://github.com/antsmartian","followers_url":"https://api.github.com/users/antsmartian/followers","following_url":"https://api.github.com/users/antsmartian/following{/other_user}","gists_url":"https://api.github.com/users/antsmartian/gists{/gist_id}","starred_url":"https://api.github.com/users/antsmartian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antsmartian/subscriptions","organizations_url":"https://api.github.com/users/antsmartian/orgs","repos_url":"https://api.github.com/users/antsmartian/repos","events_url":"https://api.github.com/users/antsmartian/events{/privacy}","received_events_url":"https://api.github.com/users/antsmartian/received_events","type":"User","site_admin":false},"body":"Hello Team, \r\n\r\nI wanted to add reverse search to repl:\r\n\r\n1. Reverse search is supported in linux and unix terminals. \r\n2. User can press `ctrl+r` to search their history \r\n3. When user types in text, we search through `node_repl_history` and show off the matching results. \r\n4. When user press enter we run the matching command on our `repl`. \r\n5. When more results found for a string, pressing `ctrl+r` again will navigate the search results one by one in a circular fashion (if we reach end of the search result). \r\n\r\n\r\nIt's a work in progress need tests, doc etc. \r\n\r\nInitial mode of working is ready. \r\n\r\n![repl-search](https://user-images.githubusercontent.com/1241511/48406108-b2a40780-e759-11e8-8c64-7b076aaab69e.gif)\r\n\r\n\r\nNeed thoughts from community on the idea. But I would love to land this on repl 😍 \r\n\r\n##### Checklist\r\n- [x] `make -j4 test` (UNIX), or `vcbuild test` (Windows) passes\r\n- [ ] tests and/or benchmarks are included\r\n- [ ] documentation is changed or added\r\n- [ ] commit message follows [commit guidelines](https://github.com/nodejs/node/blob/master/doc/guides/contributing/pull-requests.md#commit-message-guidelines)\r\n","created_at":"2018-11-13T10:02:58Z","updated_at":"2018-12-08T13:56:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5ae46e477242640c7bfeaf6c663625e0b6ddc59d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":155435874,"node_id":"MDU6TGFiZWwxNTU0MzU4NzQ=","url":"https://api.github.com/repos/nodejs/node/labels/readline","name":"readline","color":"d4c5f9","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/nodejs/node/pulls/24335/commits","review_comments_url":"https://api.github.com/repos/nodejs/node/pulls/24335/comments","review_comment_url":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodejs/node/issues/24335/comments","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/35ab75ce0b22ac059b713bc20779f1bbd7410c69","head":{"label":"antsmartian:multiline-strip-comments","ref":"multiline-strip-comments","sha":"35ab75ce0b22ac059b713bc20779f1bbd7410c69","user":{"login":"antsmartian","id":1241511,"node_id":"MDQ6VXNlcjEyNDE1MTE=","avatar_url":"https://avatars2.githubusercontent.com/u/1241511?v=4","gravatar_id":"","url":"https://api.github.com/users/antsmartian","html_url":"https://github.com/antsmartian","followers_url":"https://api.github.com/users/antsmartian/followers","following_url":"https://api.github.com/users/antsmartian/following{/other_user}","gists_url":"https://api.github.com/users/antsmartian/gists{/gist_id}","starred_url":"https://api.github.com/users/antsmartian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antsmartian/subscriptions","organizations_url":"https://api.github.com/users/antsmartian/orgs","repos_url":"https://api.github.com/users/antsmartian/repos","events_url":"https://api.github.com/users/antsmartian/events{/privacy}","received_events_url":"https://api.github.com/users/antsmartian/received_events","type":"User","site_admin":false},"repo":{"id":140859357,"node_id":"MDEwOlJlcG9zaXRvcnkxNDA4NTkzNTc=","name":"node","full_name":"antsmartian/node","private":false,"owner":{"login":"antsmartian","id":1241511,"node_id":"MDQ6VXNlcjEyNDE1MTE=","avatar_url":"https://avatars2.githubusercontent.com/u/1241511?v=4","gravatar_id":"","url":"https://api.github.com/users/antsmartian","html_url":"https://github.com/antsmartian","followers_url":"https://api.github.com/users/antsmartian/followers","following_url":"https://api.github.com/users/antsmartian/following{/other_user}","gists_url":"https://api.github.com/users/antsmartian/gists{/gist_id}","starred_url":"https://api.github.com/users/antsmartian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antsmartian/subscriptions","organizations_url":"https://api.github.com/users/antsmartian/orgs","repos_url":"https://api.github.com/users/antsmartian/repos","events_url":"https://api.github.com/users/antsmartian/events{/privacy}","received_events_url":"https://api.github.com/users/antsmartian/received_events","type":"User","site_admin":false},"html_url":"https://github.com/antsmartian/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":true,"url":"https://api.github.com/repos/antsmartian/node","forks_url":"https://api.github.com/repos/antsmartian/node/forks","keys_url":"https://api.github.com/repos/antsmartian/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/antsmartian/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/antsmartian/node/teams","hooks_url":"https://api.github.com/repos/antsmartian/node/hooks","issue_events_url":"https://api.github.com/repos/antsmartian/node/issues/events{/number}","events_url":"https://api.github.com/repos/antsmartian/node/events","assignees_url":"https://api.github.com/repos/antsmartian/node/assignees{/user}","branches_url":"https://api.github.com/repos/antsmartian/node/branches{/branch}","tags_url":"https://api.github.com/repos/antsmartian/node/tags","blobs_url":"https://api.github.com/repos/antsmartian/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/antsmartian/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/antsmartian/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/antsmartian/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/antsmartian/node/statuses/{sha}","languages_url":"https://api.github.com/repos/antsmartian/node/languages","stargazers_url":"https://api.github.com/repos/antsmartian/node/stargazers","contributors_url":"https://api.github.com/repos/antsmartian/node/contributors","subscribers_url":"https://api.github.com/repos/antsmartian/node/subscribers","subscription_url":"https://api.github.com/repos/antsmartian/node/subscription","commits_url":"https://api.github.com/repos/antsmartian/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/antsmartian/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/antsmartian/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/antsmartian/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/antsmartian/node/contents/{+path}","compare_url":"https://api.github.com/repos/antsmartian/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/antsmartian/node/merges","archive_url":"https://api.github.com/repos/antsmartian/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/antsmartian/node/downloads","issues_url":"https://api.github.com/repos/antsmartian/node/issues{/number}","pulls_url":"https://api.github.com/repos/antsmartian/node/pulls{/number}","milestones_url":"https://api.github.com/repos/antsmartian/node/milestones{/number}","notifications_url":"https://api.github.com/repos/antsmartian/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/antsmartian/node/labels{/name}","releases_url":"https://api.github.com/repos/antsmartian/node/releases{/id}","deployments_url":"https://api.github.com/repos/antsmartian/node/deployments","created_at":"2018-07-13T14:49:10Z","updated_at":"2018-07-13T14:49:34Z","pushed_at":"2018-12-08T07:52:35Z","git_url":"git://github.com/antsmartian/node.git","ssh_url":"git@github.com:antsmartian/node.git","clone_url":"https://github.com/antsmartian/node.git","svn_url":"https://github.com/antsmartian/node","homepage":"https://nodejs.org","size":433465,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nodejs:master","ref":"master","sha":"b5e9086c5a6553d0d7ad6006ac83ed881c35fcdd","user":{"login":"nodejs","id":9950313,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk5NTAzMTM=","avatar_url":"https://avatars3.githubusercontent.com/u/9950313?v=4","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"repo":{"id":27193779,"node_id":"MDEwOlJlcG9zaXRvcnkyNzE5Mzc3OQ==","name":"node","full_name":"nodejs/node","private":false,"owner":{"login":"nodejs","id":9950313,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk5NTAzMTM=","avatar_url":"https://avatars3.githubusercontent.com/u/9950313?v=4","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/nodejs/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":false,"url":"https://api.github.com/repos/nodejs/node","forks_url":"https://api.github.com/repos/nodejs/node/forks","keys_url":"https://api.github.com/repos/nodejs/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodejs/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodejs/node/teams","hooks_url":"https://api.github.com/repos/nodejs/node/hooks","issue_events_url":"https://api.github.com/repos/nodejs/node/issues/events{/number}","events_url":"https://api.github.com/repos/nodejs/node/events","assignees_url":"https://api.github.com/repos/nodejs/node/assignees{/user}","branches_url":"https://api.github.com/repos/nodejs/node/branches{/branch}","tags_url":"https://api.github.com/repos/nodejs/node/tags","blobs_url":"https://api.github.com/repos/nodejs/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodejs/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodejs/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodejs/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/{sha}","languages_url":"https://api.github.com/repos/nodejs/node/languages","stargazers_url":"https://api.github.com/repos/nodejs/node/stargazers","contributors_url":"https://api.github.com/repos/nodejs/node/contributors","subscribers_url":"https://api.github.com/repos/nodejs/node/subscribers","subscription_url":"https://api.github.com/repos/nodejs/node/subscription","commits_url":"https://api.github.com/repos/nodejs/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodejs/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodejs/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodejs/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodejs/node/contents/{+path}","compare_url":"https://api.github.com/repos/nodejs/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodejs/node/merges","archive_url":"https://api.github.com/repos/nodejs/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodejs/node/downloads","issues_url":"https://api.github.com/repos/nodejs/node/issues{/number}","pulls_url":"https://api.github.com/repos/nodejs/node/pulls{/number}","milestones_url":"https://api.github.com/repos/nodejs/node/milestones{/number}","notifications_url":"https://api.github.com/repos/nodejs/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodejs/node/labels{/name}","releases_url":"https://api.github.com/repos/nodejs/node/releases{/id}","deployments_url":"https://api.github.com/repos/nodejs/node/deployments","created_at":"2014-11-26T19:57:11Z","updated_at":"2018-12-08T13:09:41Z","pushed_at":"2018-12-08T13:51:37Z","git_url":"git://github.com/nodejs/node.git","ssh_url":"git@github.com:nodejs/node.git","clone_url":"https://github.com/nodejs/node.git","svn_url":"https://github.com/nodejs/node","homepage":"https://nodejs.org","size":440798,"stargazers_count":56204,"watchers_count":56204,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12398,"mirror_url":null,"archived":false,"open_issues_count":720,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":12398,"open_issues":720,"watchers":56204,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/24335"},"html":{"href":"https://github.com/nodejs/node/pull/24335"},"issue":{"href":"https://api.github.com/repos/nodejs/node/issues/24335"},"comments":{"href":"https://api.github.com/repos/nodejs/node/issues/24335/comments"},"review_comments":{"href":"https://api.github.com/repos/nodejs/node/pulls/24335/comments"},"review_comment":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodejs/node/pulls/24335/commits"},"statuses":{"href":"https://api.github.com/repos/nodejs/node/statuses/35ab75ce0b22ac059b713bc20779f1bbd7410c69"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"BridgeAR"}}