{"action":"created","issue":{"url":"https://api.github.com/repos/python-mode/python-mode/issues/957","repository_url":"https://api.github.com/repos/python-mode/python-mode","labels_url":"https://api.github.com/repos/python-mode/python-mode/issues/957/labels{/name}","comments_url":"https://api.github.com/repos/python-mode/python-mode/issues/957/comments","events_url":"https://api.github.com/repos/python-mode/python-mode/issues/957/events","html_url":"https://github.com/python-mode/python-mode/pull/957","id":377715705,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI4NTkxNTI4","number":957,"title":"Fix off by one selection of extract variable/method","user":{"login":"lieryan","id":1006989,"node_id":"MDQ6VXNlcjEwMDY5ODk=","avatar_url":"https://avatars3.githubusercontent.com/u/1006989?v=4","gravatar_id":"","url":"https://api.github.com/users/lieryan","html_url":"https://github.com/lieryan","followers_url":"https://api.github.com/users/lieryan/followers","following_url":"https://api.github.com/users/lieryan/following{/other_user}","gists_url":"https://api.github.com/users/lieryan/gists{/gist_id}","starred_url":"https://api.github.com/users/lieryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lieryan/subscriptions","organizations_url":"https://api.github.com/users/lieryan/orgs","repos_url":"https://api.github.com/users/lieryan/repos","events_url":"https://api.github.com/users/lieryan/events{/privacy}","received_events_url":"https://api.github.com/users/lieryan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-11-06T07:00:22Z","updated_at":"2019-01-05T22:37:19Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/python-mode/python-mode/pulls/957","html_url":"https://github.com/python-mode/python-mode/pull/957","diff_url":"https://github.com/python-mode/python-mode/pull/957.diff","patch_url":"https://github.com/python-mode/python-mode/pull/957.patch"},"body":"Currently, extract variable and method uses the left side of the visual selection cursor to select range for both sides of the visual selection cursors. This is an incorrect selection behaviour and is inconsistent with how vim normally select texts, which is to use the left side of the left selection cursor but the right side of the right selection cursor. For example, suppose that you have a file with this code, and you place your cursor anywhere in the middle of the text \"hello world\":\r\n\r\n    test(\"hello world\")\r\n\r\nCurrently, the more intuitive `vi(<C-c>rl` will visually select the text range `\"hello world\"` and essentially do a `:call pymode#rope#extract_variable()`. However, this currently would produce this error:\r\n\r\n    [Pymode]: error: Extracted piece should contain complete statements.\r\n\r\nAs a workaround, you can do `vi(l<C-c>rl` to select `\"hello world\")` instead, but this is inconsistent with how Vim text object selection normally works and it takes an extra keystroke (for example, if you want to delete \"hello cursor there\" you simply do it using `di(`, no additional `l`).\r\n\r\nThis PR changes the offset calculation to be more typical to normal Vim behaviour. With the change in this PR, selecting `\"hello world\"` with `vi(` and then calling `pymode#rope#extract_variable()` with `<C-c>rl` should give you the \"Extract variable\" prompt:\r\n\r\n    [Pymode]  Extract variable. \r\n    [Pymode] New variable name: > \r\n"},"comment":{"url":"https://api.github.com/repos/python-mode/python-mode/issues/comments/451697659","html_url":"https://github.com/python-mode/python-mode/pull/957#issuecomment-451697659","issue_url":"https://api.github.com/repos/python-mode/python-mode/issues/957","id":451697659,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MTY5NzY1OQ==","user":{"login":"diraol","id":192702,"node_id":"MDQ6VXNlcjE5MjcwMg==","avatar_url":"https://avatars1.githubusercontent.com/u/192702?v=4","gravatar_id":"","url":"https://api.github.com/users/diraol","html_url":"https://github.com/diraol","followers_url":"https://api.github.com/users/diraol/followers","following_url":"https://api.github.com/users/diraol/following{/other_user}","gists_url":"https://api.github.com/users/diraol/gists{/gist_id}","starred_url":"https://api.github.com/users/diraol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diraol/subscriptions","organizations_url":"https://api.github.com/users/diraol/orgs","repos_url":"https://api.github.com/users/diraol/repos","events_url":"https://api.github.com/users/diraol/events{/privacy}","received_events_url":"https://api.github.com/users/diraol/received_events","type":"User","site_admin":false},"created_at":"2019-01-05T22:37:19Z","updated_at":"2019-01-05T22:37:19Z","author_association":"CONTRIBUTOR","body":"Thanks @lieryan ! I've made the tests and was able to see your PR working! ;) Thanks!"}}
{"actor":{"display_login":"diraol"}}