{"action":"created","comment":{"url":"https://api.github.com/repos/neovim/neovim/pulls/comments/28206769","id":28206769,"diff_hunk":"@@ -790,61 +780,45 @@ void get_yank_register(int regname, int mode)\n     i = CharOrdLow(regname) + 10;\n   else if (ASCII_ISUPPER(regname)) {\n     i = CharOrdUp(regname) + 10;\n-    y_append = true;\n   } else if (regname == '-')\n     i = DELETION_REGISTER;\n   else if (regname == '*')\n     i = STAR_REGISTER;\n   else if (regname == '+')\n     i = PLUS_REGISTER;\n-  y_current = &(y_regs[i]);\n+  reg = &y_regs[i];\n \n   if (mode == YREG_YANK) {\n     // remember the written register for unnamed paste\n-    y_previous = y_current;\n+    y_previous = reg;\n   }\n+  return reg;\n }\n \n-\n-/*\n- * Obtain the contents of a \"normal\" register. The register is made empty.\n- * The returned pointer has allocated memory, use put_register() later.\n- */\n-void *\n-get_register (\n-    int name,\n-    int copy               /* make a copy, if FALSE make register empty. */\n-) FUNC_ATTR_NONNULL_RET\n+static bool is_append_register(int regname)\n {\n-  get_yank_register(name, YREG_PASTE);\n-\n-  struct yankreg *reg = xmalloc(sizeof(struct yankreg));\n-  *reg = *y_current;\n-  if (copy) {\n-    if (reg->y_size == 0) {\n-      reg->y_array = NULL;\n-    } else {\n-      reg->y_array = xmalloc(reg->y_size * sizeof(char_u *));\n-      for (linenr_T i = 0; i < reg->y_size; ++i) {\n-        reg->y_array[i] = vim_strsave(y_current->y_array[i]);\n-      }\n-    }\n-  } else\n-    y_current->y_array = NULL;\n-\n-  return (void *)reg;\n+  return ASCII_ISUPPER(regname);\n }\n \n-/*\n- * Put \"reg\" into register \"name\".  Free any previous contents and \"reg\".\n- */\n-void put_register(int name, void *reg)\n+/// return copy of contents in register `name`\n+/// for use in do_put. Should be freed by caller.\n+yankreg_T *copy_register(int name)\n+  FUNC_ATTR_MALLOC\n+  FUNC_ATTR_NONNULL_RET\n {\n-  get_yank_register(name, YREG_PUT);\n-  free_yank_all();\n-  *y_current = *(struct yankreg *)reg;\n-  free(reg);\n-  set_clipboard(name);\n+  yankreg_T *reg = get_yank_register(name, YREG_PASTE);\n+\n+  yankreg_T *copy = xmalloc(sizeof(yankreg_T));\n+  *copy = *reg;\n+  if (copy->y_size == 0) {\n+    copy->y_array = NULL;\n+  } else {\n+    copy->y_array = xmalloc(copy->y_size * sizeof(char_u *));\n+    for (linenr_T i = 0; i < copy->y_size; ++i) {","path":"src/nvim/ops.c","position":132,"original_position":132,"commit_id":"8b0601a131edd2c83b5c444869f87a50a851c69f","original_commit_id":"8b0601a131edd2c83b5c444869f87a50a851c69f","user":{"login":"Pyrohh","id":4174345,"avatar_url":"https://avatars.githubusercontent.com/u/4174345?v=3","gravatar_id":"","url":"https://api.github.com/users/Pyrohh","html_url":"https://github.com/Pyrohh","followers_url":"https://api.github.com/users/Pyrohh/followers","following_url":"https://api.github.com/users/Pyrohh/following{/other_user}","gists_url":"https://api.github.com/users/Pyrohh/gists{/gist_id}","starred_url":"https://api.github.com/users/Pyrohh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pyrohh/subscriptions","organizations_url":"https://api.github.com/users/Pyrohh/orgs","repos_url":"https://api.github.com/users/Pyrohh/repos","events_url":"https://api.github.com/users/Pyrohh/events{/privacy}","received_events_url":"https://api.github.com/users/Pyrohh/received_events","type":"User","site_admin":false},"body":"`++i` -> `i++`","created_at":"2015-04-12T20:00:27Z","updated_at":"2015-04-12T20:00:27Z","html_url":"https://github.com/neovim/neovim/pull/2411#discussion_r28206769","pull_request_url":"https://api.github.com/repos/neovim/neovim/pulls/2411","_links":{"self":{"href":"https://api.github.com/repos/neovim/neovim/pulls/comments/28206769"},"html":{"href":"https://github.com/neovim/neovim/pull/2411#discussion_r28206769"},"pull_request":{"href":"https://api.github.com/repos/neovim/neovim/pulls/2411"}}},"pull_request":{"url":"https://api.github.com/repos/neovim/neovim/pulls/2411","id":33109421,"html_url":"https://github.com/neovim/neovim/pull/2411","diff_url":"https://github.com/neovim/neovim/pull/2411.diff","patch_url":"https://github.com/neovim/neovim/pull/2411.patch","issue_url":"https://api.github.com/repos/neovim/neovim/issues/2411","number":2411,"state":"open","locked":false,"title":"[WIP] some register cleanups","user":{"login":"bfredl","id":1363104,"avatar_url":"https://avatars.githubusercontent.com/u/1363104?v=3","gravatar_id":"","url":"https://api.github.com/users/bfredl","html_url":"https://github.com/bfredl","followers_url":"https://api.github.com/users/bfredl/followers","following_url":"https://api.github.com/users/bfredl/following{/other_user}","gists_url":"https://api.github.com/users/bfredl/gists{/gist_id}","starred_url":"https://api.github.com/users/bfredl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bfredl/subscriptions","organizations_url":"https://api.github.com/users/bfredl/orgs","repos_url":"https://api.github.com/users/bfredl/repos","events_url":"https://api.github.com/users/bfredl/events{/privacy}","received_events_url":"https://api.github.com/users/bfredl/received_events","type":"User","site_admin":false},"body":"Remove static `y_current` and `y_append` and pass `yankreg`s as arguments/return values instead. Eliminates some code of this style:\r\n```\r\n  struct yankreg *curr = y_current;\r\n  // Set it to 'y_current' since 'free_yank_all' operates on it\r\n  y_current = reg;\r\n  free_yank_all();\r\n  // Restore 'y_current'\r\n  y_current = curr;\r\n```\r\nAlso make paste in visual mode (`viwp` and such) simpler and avoid spurious clipboard provider calls when `clipboard=unnamed`. \r\n\r\nSome more work to be done like cleaning up bools and function docs.","created_at":"2015-04-11T20:26:45Z","updated_at":"2015-04-12T20:00:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b9a0b99b7c4f7d1c80c8564279a45b037285caa2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/neovim/neovim/pulls/2411/commits","review_comments_url":"https://api.github.com/repos/neovim/neovim/pulls/2411/comments","review_comment_url":"https://api.github.com/repos/neovim/neovim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/neovim/neovim/issues/2411/comments","statuses_url":"https://api.github.com/repos/neovim/neovim/statuses/8b0601a131edd2c83b5c444869f87a50a851c69f","head":{"label":"bfredl:yankregs","ref":"yankregs","sha":"8b0601a131edd2c83b5c444869f87a50a851c69f","user":{"login":"bfredl","id":1363104,"avatar_url":"https://avatars.githubusercontent.com/u/1363104?v=3","gravatar_id":"","url":"https://api.github.com/users/bfredl","html_url":"https://github.com/bfredl","followers_url":"https://api.github.com/users/bfredl/followers","following_url":"https://api.github.com/users/bfredl/following{/other_user}","gists_url":"https://api.github.com/users/bfredl/gists{/gist_id}","starred_url":"https://api.github.com/users/bfredl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bfredl/subscriptions","organizations_url":"https://api.github.com/users/bfredl/orgs","repos_url":"https://api.github.com/users/bfredl/repos","events_url":"https://api.github.com/users/bfredl/events{/privacy}","received_events_url":"https://api.github.com/users/bfredl/received_events","type":"User","site_admin":false},"repo":{"id":21050434,"name":"neovim","full_name":"bfredl/neovim","owner":{"login":"bfredl","id":1363104,"avatar_url":"https://avatars.githubusercontent.com/u/1363104?v=3","gravatar_id":"","url":"https://api.github.com/users/bfredl","html_url":"https://github.com/bfredl","followers_url":"https://api.github.com/users/bfredl/followers","following_url":"https://api.github.com/users/bfredl/following{/other_user}","gists_url":"https://api.github.com/users/bfredl/gists{/gist_id}","starred_url":"https://api.github.com/users/bfredl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bfredl/subscriptions","organizations_url":"https://api.github.com/users/bfredl/orgs","repos_url":"https://api.github.com/users/bfredl/repos","events_url":"https://api.github.com/users/bfredl/events{/privacy}","received_events_url":"https://api.github.com/users/bfredl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bfredl/neovim","description":"vim's rebirth for the 21st century","fork":true,"url":"https://api.github.com/repos/bfredl/neovim","forks_url":"https://api.github.com/repos/bfredl/neovim/forks","keys_url":"https://api.github.com/repos/bfredl/neovim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bfredl/neovim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bfredl/neovim/teams","hooks_url":"https://api.github.com/repos/bfredl/neovim/hooks","issue_events_url":"https://api.github.com/repos/bfredl/neovim/issues/events{/number}","events_url":"https://api.github.com/repos/bfredl/neovim/events","assignees_url":"https://api.github.com/repos/bfredl/neovim/assignees{/user}","branches_url":"https://api.github.com/repos/bfredl/neovim/branches{/branch}","tags_url":"https://api.github.com/repos/bfredl/neovim/tags","blobs_url":"https://api.github.com/repos/bfredl/neovim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bfredl/neovim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bfredl/neovim/git/refs{/sha}","trees_url":"https://api.github.com/repos/bfredl/neovim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bfredl/neovim/statuses/{sha}","languages_url":"https://api.github.com/repos/bfredl/neovim/languages","stargazers_url":"https://api.github.com/repos/bfredl/neovim/stargazers","contributors_url":"https://api.github.com/repos/bfredl/neovim/contributors","subscribers_url":"https://api.github.com/repos/bfredl/neovim/subscribers","subscription_url":"https://api.github.com/repos/bfredl/neovim/subscription","commits_url":"https://api.github.com/repos/bfredl/neovim/commits{/sha}","git_commits_url":"https://api.github.com/repos/bfredl/neovim/git/commits{/sha}","comments_url":"https://api.github.com/repos/bfredl/neovim/comments{/number}","issue_comment_url":"https://api.github.com/repos/bfredl/neovim/issues/comments{/number}","contents_url":"https://api.github.com/repos/bfredl/neovim/contents/{+path}","compare_url":"https://api.github.com/repos/bfredl/neovim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bfredl/neovim/merges","archive_url":"https://api.github.com/repos/bfredl/neovim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bfredl/neovim/downloads","issues_url":"https://api.github.com/repos/bfredl/neovim/issues{/number}","pulls_url":"https://api.github.com/repos/bfredl/neovim/pulls{/number}","milestones_url":"https://api.github.com/repos/bfredl/neovim/milestones{/number}","notifications_url":"https://api.github.com/repos/bfredl/neovim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bfredl/neovim/labels{/name}","releases_url":"https://api.github.com/repos/bfredl/neovim/releases{/id}","created_at":"2014-06-20T19:51:31Z","updated_at":"2014-06-20T19:51:31Z","pushed_at":"2015-04-12T17:43:09Z","git_url":"git://github.com/bfredl/neovim.git","ssh_url":"git@github.com:bfredl/neovim.git","clone_url":"https://github.com/bfredl/neovim.git","svn_url":"https://github.com/bfredl/neovim","homepage":"http://neovim.org/","size":30657,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"neovim:master","ref":"master","sha":"fb6e9312684b0f1bd60822d7da04ba6901b1e48b","user":{"login":"neovim","id":6471485,"avatar_url":"https://avatars.githubusercontent.com/u/6471485?v=3","gravatar_id":"","url":"https://api.github.com/users/neovim","html_url":"https://github.com/neovim","followers_url":"https://api.github.com/users/neovim/followers","following_url":"https://api.github.com/users/neovim/following{/other_user}","gists_url":"https://api.github.com/users/neovim/gists{/gist_id}","starred_url":"https://api.github.com/users/neovim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neovim/subscriptions","organizations_url":"https://api.github.com/users/neovim/orgs","repos_url":"https://api.github.com/users/neovim/repos","events_url":"https://api.github.com/users/neovim/events{/privacy}","received_events_url":"https://api.github.com/users/neovim/received_events","type":"Organization","site_admin":false},"repo":{"id":16408992,"name":"neovim","full_name":"neovim/neovim","owner":{"login":"neovim","id":6471485,"avatar_url":"https://avatars.githubusercontent.com/u/6471485?v=3","gravatar_id":"","url":"https://api.github.com/users/neovim","html_url":"https://github.com/neovim","followers_url":"https://api.github.com/users/neovim/followers","following_url":"https://api.github.com/users/neovim/following{/other_user}","gists_url":"https://api.github.com/users/neovim/gists{/gist_id}","starred_url":"https://api.github.com/users/neovim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neovim/subscriptions","organizations_url":"https://api.github.com/users/neovim/orgs","repos_url":"https://api.github.com/users/neovim/repos","events_url":"https://api.github.com/users/neovim/events{/privacy}","received_events_url":"https://api.github.com/users/neovim/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/neovim/neovim","description":"vim out of the box","fork":false,"url":"https://api.github.com/repos/neovim/neovim","forks_url":"https://api.github.com/repos/neovim/neovim/forks","keys_url":"https://api.github.com/repos/neovim/neovim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/neovim/neovim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/neovim/neovim/teams","hooks_url":"https://api.github.com/repos/neovim/neovim/hooks","issue_events_url":"https://api.github.com/repos/neovim/neovim/issues/events{/number}","events_url":"https://api.github.com/repos/neovim/neovim/events","assignees_url":"https://api.github.com/repos/neovim/neovim/assignees{/user}","branches_url":"https://api.github.com/repos/neovim/neovim/branches{/branch}","tags_url":"https://api.github.com/repos/neovim/neovim/tags","blobs_url":"https://api.github.com/repos/neovim/neovim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/neovim/neovim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/neovim/neovim/git/refs{/sha}","trees_url":"https://api.github.com/repos/neovim/neovim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/neovim/neovim/statuses/{sha}","languages_url":"https://api.github.com/repos/neovim/neovim/languages","stargazers_url":"https://api.github.com/repos/neovim/neovim/stargazers","contributors_url":"https://api.github.com/repos/neovim/neovim/contributors","subscribers_url":"https://api.github.com/repos/neovim/neovim/subscribers","subscription_url":"https://api.github.com/repos/neovim/neovim/subscription","commits_url":"https://api.github.com/repos/neovim/neovim/commits{/sha}","git_commits_url":"https://api.github.com/repos/neovim/neovim/git/commits{/sha}","comments_url":"https://api.github.com/repos/neovim/neovim/comments{/number}","issue_comment_url":"https://api.github.com/repos/neovim/neovim/issues/comments{/number}","contents_url":"https://api.github.com/repos/neovim/neovim/contents/{+path}","compare_url":"https://api.github.com/repos/neovim/neovim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/neovim/neovim/merges","archive_url":"https://api.github.com/repos/neovim/neovim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/neovim/neovim/downloads","issues_url":"https://api.github.com/repos/neovim/neovim/issues{/number}","pulls_url":"https://api.github.com/repos/neovim/neovim/pulls{/number}","milestones_url":"https://api.github.com/repos/neovim/neovim/milestones{/number}","notifications_url":"https://api.github.com/repos/neovim/neovim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/neovim/neovim/labels{/name}","releases_url":"https://api.github.com/repos/neovim/neovim/releases{/id}","created_at":"2014-01-31T13:39:22Z","updated_at":"2015-04-12T19:39:12Z","pushed_at":"2015-04-12T19:40:25Z","git_url":"git://github.com/neovim/neovim.git","ssh_url":"git@github.com:neovim/neovim.git","clone_url":"https://github.com/neovim/neovim.git","svn_url":"https://github.com/neovim/neovim","homepage":"http://neovim.org","size":61371,"stargazers_count":12861,"watchers_count":12861,"language":"VimL","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":866,"mirror_url":null,"open_issues_count":440,"forks":866,"open_issues":440,"watchers":12861,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/neovim/neovim/pulls/2411"},"html":{"href":"https://github.com/neovim/neovim/pull/2411"},"issue":{"href":"https://api.github.com/repos/neovim/neovim/issues/2411"},"comments":{"href":"https://api.github.com/repos/neovim/neovim/issues/2411/comments"},"review_comments":{"href":"https://api.github.com/repos/neovim/neovim/pulls/2411/comments"},"review_comment":{"href":"https://api.github.com/repos/neovim/neovim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/neovim/neovim/pulls/2411/commits"},"statuses":{"href":"https://api.github.com/repos/neovim/neovim/statuses/8b0601a131edd2c83b5c444869f87a50a851c69f"}}}}