{"action":"created","comment":{"url":"https://api.github.com/repos/neovim/neovim/pulls/comments/55371063","id":55371063,"diff_hunk":"@@ -68,14 +69,16 @@ describe('buffer_* functions', function()\n       eq({}, curbuf('get_line_slice', -4, -5, true, true))\n     end)\n \n-    it('set_line_slice: out-of-bounds is an error', function()\n+    it('set_line_slice: out-of-bounds extends past end', function()\n       curbuf('set_line_slice', 0, 0, true, true, {'a', 'b', 'c'})\n       eq({'a', 'b', 'c'}, curbuf('get_line_slice', 0, 2, true, true)) --sanity\n \n       eq({'c'}, curbuf('get_line_slice', -1, 4, true, true))\n       eq({'a', 'b', 'c'}, curbuf('get_line_slice', 0, 5, true, true))\n-      eq(false, pcall(curbuf, 'set_line_slice', 4, 5, true, true, {'d'}))\n-      eq(false, pcall(curbuf, 'set_line_slice', -4, -5, true, true, {'d'}))\n+      curbuf('set_line_slice', 4, 5, true, true, {'d'})\n+      eq({'a', 'b', 'c', 'd'}, curbuf('get_line_slice', 0, 5, true, true))\n+      curbuf('set_line_slice', -4, -5, true, true, {'e'})\n+      eq({'e', 'a', 'b', 'c', 'd'}, curbuf('get_line_slice', 0, 5, true, true))","path":"test/functional/api/buffer_spec.lua","position":31,"original_position":31,"commit_id":"3f58f9c4adde43a4feda4ff43bc24d7336a7eabe","original_commit_id":"3f58f9c4adde43a4feda4ff43bc24d7336a7eabe","user":{"login":"justinmk","id":1359421,"avatar_url":"https://avatars.githubusercontent.com/u/1359421?v=3","gravatar_id":"","url":"https://api.github.com/users/justinmk","html_url":"https://github.com/justinmk","followers_url":"https://api.github.com/users/justinmk/followers","following_url":"https://api.github.com/users/justinmk/following{/other_user}","gists_url":"https://api.github.com/users/justinmk/gists{/gist_id}","starred_url":"https://api.github.com/users/justinmk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinmk/subscriptions","organizations_url":"https://api.github.com/users/justinmk/orgs","repos_url":"https://api.github.com/users/justinmk/repos","events_url":"https://api.github.com/users/justinmk/events{/privacy}","received_events_url":"https://api.github.com/users/justinmk/received_events","type":"User","site_admin":false},"body":"Is there a test for strict indexing?","created_at":"2016-03-08T15:07:07Z","updated_at":"2016-03-08T15:07:07Z","html_url":"https://github.com/neovim/neovim/pull/4083#discussion_r55371063","pull_request_url":"https://api.github.com/repos/neovim/neovim/pulls/4083","_links":{"self":{"href":"https://api.github.com/repos/neovim/neovim/pulls/comments/55371063"},"html":{"href":"https://github.com/neovim/neovim/pull/4083#discussion_r55371063"},"pull_request":{"href":"https://api.github.com/repos/neovim/neovim/pulls/4083"}}},"pull_request":{"url":"https://api.github.com/repos/neovim/neovim/pulls/4083","id":56985154,"html_url":"https://github.com/neovim/neovim/pull/4083","diff_url":"https://github.com/neovim/neovim/pull/4083.diff","patch_url":"https://github.com/neovim/neovim/pull/4083.patch","issue_url":"https://api.github.com/repos/neovim/neovim/issues/4083","number":4083,"state":"open","locked":false,"title":"[RFC] api/buffer: out-of-bounds handling, next take","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":"Step one was to make things consistent with the vim python interface, so fixes neovim/python-client#155 and #4058 . Though that is probably too narrow an aim. We might to add a flag to toggle bound checking of the slice functions, to also accommodate languages with stricter range semantics.\r\n\r\nThe index handling is a confusing mixture of offset and element based indexing, with implementation arbitararily split between `[gs]et_slice` and two helper functions (not anyone's fault in particular, just a result of our fix-a-bug-at-a-time approach.) But it was not messier than the missing corner case could be inferred like so:\r\n```\r\n  include_start = include_start && (start < buf->b_ml.ml_line_count); // added\r\n  start = normalize_index(buf, start) + (include_start ? 0 : 1);\r\n  include_end = include_end || (end >= buf->b_ml.ml_line_count);\r\n  end = normalize_index(buf, end) + (include_end ? 1 : 0);\r\n```\r\n\r\nNext step might be to try to simplify the implementation, or even so the API.  Do we really need to support both offset (0-based) and element (1-based) indexing at the API-level, as controlled by the include_start and include_end parameters ? This multiplies the different cases to support, and test, as highlighted by this missing corner case. The only limitation to use pure offset indexing (python-style) is that there is no numerical value for the index-past-the-end. Either we could have a magic value, like INT32_MAX to designate this index (leaks a implementation limit to the API, so a bit unclean) or we could use a slightly modified scheme, where -1 is the index-past-the-end and -2 is the last element etc (but this would make us different than anyone else, so still not 100% happy). IMHO even having a dedicated flag just for this position is cleaner than  `include_start`, but that is debatable.\r\n\r\nThoughts? Ideas?","created_at":"2016-01-23T20:08:56Z","updated_at":"2016-03-08T15:07:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e7bf6c450224c26f4ddfc1c2bdd388d64dc37546","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/neovim/neovim/pulls/4083/commits","review_comments_url":"https://api.github.com/repos/neovim/neovim/pulls/4083/comments","review_comment_url":"https://api.github.com/repos/neovim/neovim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/neovim/neovim/issues/4083/comments","statuses_url":"https://api.github.com/repos/neovim/neovim/statuses/3f58f9c4adde43a4feda4ff43bc24d7336a7eabe","head":{"label":"bfredl:oob","ref":"oob","sha":"3f58f9c4adde43a4feda4ff43bc24d7336a7eabe","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}","deployments_url":"https://api.github.com/repos/bfredl/neovim/deployments","created_at":"2014-06-20T19:51:31Z","updated_at":"2014-06-20T19:51:31Z","pushed_at":"2016-03-08T10:23:11Z","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":38812,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"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":"37b3a4c607a1305ce56e96837e305fd637fde0e8","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-fork focused on extensibility and agility. Consider helping sustain Neovim development! ","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}","deployments_url":"https://api.github.com/repos/neovim/neovim/deployments","created_at":"2014-01-31T13:39:22Z","updated_at":"2016-03-08T14:03:55Z","pushed_at":"2016-03-08T14:46:57Z","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":"https://salt.bountysource.com/teams/neovim","size":60067,"stargazers_count":17578,"watchers_count":17578,"language":"VimL","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1258,"mirror_url":null,"open_issues_count":643,"forks":1258,"open_issues":643,"watchers":17578,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/neovim/neovim/pulls/4083"},"html":{"href":"https://github.com/neovim/neovim/pull/4083"},"issue":{"href":"https://api.github.com/repos/neovim/neovim/issues/4083"},"comments":{"href":"https://api.github.com/repos/neovim/neovim/issues/4083/comments"},"review_comments":{"href":"https://api.github.com/repos/neovim/neovim/pulls/4083/comments"},"review_comment":{"href":"https://api.github.com/repos/neovim/neovim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/neovim/neovim/pulls/4083/commits"},"statuses":{"href":"https://api.github.com/repos/neovim/neovim/statuses/3f58f9c4adde43a4feda4ff43bc24d7336a7eabe"}}}}