{"action":"created","issue":{"url":"https://api.github.com/repos/vim/vim/issues/679","repository_url":"https://api.github.com/repos/vim/vim","labels_url":"https://api.github.com/repos/vim/vim/issues/679/labels{/name}","comments_url":"https://api.github.com/repos/vim/vim/issues/679/comments","events_url":"https://api.github.com/repos/vim/vim/issues/679/events","html_url":"https://github.com/vim/vim/issues/679","id":139115066,"number":679,"title":"TextChangedI gets triggered for i_CTRL-P without any changes","user":{"login":"blueyed","id":9766,"avatar_url":"https://avatars.githubusercontent.com/u/9766?v=3","gravatar_id":"","url":"https://api.github.com/users/blueyed","html_url":"https://github.com/blueyed","followers_url":"https://api.github.com/users/blueyed/followers","following_url":"https://api.github.com/users/blueyed/following{/other_user}","gists_url":"https://api.github.com/users/blueyed/gists{/gist_id}","starred_url":"https://api.github.com/users/blueyed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blueyed/subscriptions","organizations_url":"https://api.github.com/users/blueyed/orgs","repos_url":"https://api.github.com/users/blueyed/repos","events_url":"https://api.github.com/users/blueyed/events{/privacy}","received_events_url":"https://api.github.com/users/blueyed/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-07T22:33:29Z","updated_at":"2016-03-09T01:15:48Z","closed_at":null,"body":"`b:changedtick` gets changed and triggers `TextChangedI` although there might be no changes:\r\n\r\n1. vim -u NONE -N\r\n2. `ifoo<Esc>`\r\n3. `:echom b:changedtick`\r\n=> 5\r\n4. `a<Esc>`\r\n5. `:echom b:changedtick`\r\n=> 5  (OK)\r\n6. `a<C-p>`\r\n=> \"-- Keyword completion (^N^P) Pattern not found\"\r\n7. `<Esc>:echom b:changedtick`\r\n=> 11\r\n\r\nNote that this is `len(\"foo\") * 2`.\r\n\r\nThis is likely caused by Vim replacing the word itself with itself internally?!\r\n\r\nThis is a bit problematic in the context of completions, because it will not display the popup menu with completions, but might re-trigger e.g. deoplete (which hooks into TextChangedI).\r\n\r\nI could not reproduce it using the following btw:\r\n\r\n    vim -u NONE --cmd 'norm ifoo' --cmd 'echom b:changedtick' --cmd 'call feedkeys(\"a\\<C-p>\\<Esc>\")' --cmd 'echom b:changedtick'\r\n\r\nIf this cannot be fixed internally to not change `b:changedtick`, it should at least not trigger `TextChangedI` / `TextChanged` probably.\r\n\r\n/cc @Shougo (because I've noticed this in the context of deoplete; Neovim is affected as well)"},"comment":{"url":"https://api.github.com/repos/vim/vim/issues/comments/194053546","html_url":"https://github.com/vim/vim/issues/679#issuecomment-194053546","issue_url":"https://api.github.com/repos/vim/vim/issues/679","id":194053546,"user":{"login":"vim-ml","id":11653528,"avatar_url":"https://avatars.githubusercontent.com/u/11653528?v=3","gravatar_id":"","url":"https://api.github.com/users/vim-ml","html_url":"https://github.com/vim-ml","followers_url":"https://api.github.com/users/vim-ml/followers","following_url":"https://api.github.com/users/vim-ml/following{/other_user}","gists_url":"https://api.github.com/users/vim-ml/gists{/gist_id}","starred_url":"https://api.github.com/users/vim-ml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vim-ml/subscriptions","organizations_url":"https://api.github.com/users/vim-ml/orgs","repos_url":"https://api.github.com/users/vim-ml/repos","events_url":"https://api.github.com/users/vim-ml/events{/privacy}","received_events_url":"https://api.github.com/users/vim-ml/received_events","type":"User","site_admin":false},"created_at":"2016-03-09T01:15:48Z","updated_at":"2016-03-09T01:15:48Z","body":"Hi,\n\n2016-3-8(Tue) 8:05:08 UTC+9 ZyX:\n> 2016-03-08 1:33 GMT+03:00 Daniel Hahler <vim-dev...@256bit.org>:\n> \n> b:changedtick gets changed and triggers TextChangedI although there might be no changes:\n> \n> \n> vim -u NONE -N\n> ifoo<Esc>\n> \n> :echom b:changedtick\n> => 5\n> a<Esc>\n> \n> :echom b:changedtick\n> => 5  (OK)\n> \n> a<C-p>\n> => \"-- Keyword completion (^N^P) Pattern not found\"\n> \n> <Esc>:echom b:changedtick\n> => 11\n> \n> \n> \n> Note that this is len(\"foo\") * 2.\n> \n> \n> This is likely caused by Vim replacing the word itself with itself internally?!\n> \n> \n> This is a bit problematic in the context of completions, because it will not display the popup menu with completions, but might re-trigger e.g. deoplete (which hooks into TextChangedI).\n> \n> \n> I could not reproduce it using the following btw:\n> \n> vim -u NONE --cmd 'norm ifoo' --cmd 'echom b:changedtick' --cmd 'call feedkeys(\"a\\<C-p>\\<Esc>\")' --cmd 'echom b:changedtick'\n> \n> \n> \n> ​You cannot do this because you do not understand when `feedkeys()` are processed. It *first* runs second `:echomsg b:changedtick` and *then* processes `a<C-p><Esc>`. Use `normal` or write `:echomsg b:changedtick\\n` right after `\\<Esc>`:\n\nNot it if you specify the \"x\" to the second argument of the feedkeys().\n\ndocument:\nhttps://github.com/vim/vim/blob/master/runtime/doc/eval.txt#L3357-L3361\n\nsample:\nhttps://github.com/vim/vim/blob/master/src/testdir/test_packadd.vim#L77\n\n--\nBest regards,\nHirohito Higashi (a.k.a. h_east)\n\n> \n> \n>     ​vim -u NONE --cmd 'call setline(1, \"foo\")' --cmd 'echom b:changedtick' --cmd 'execute \"normal!\" \"a\\<C-p>\\e\"' --cmd 'echomsg b:changedtick' --cmd cq\n> \n> \n> : this produces 3 (first changedtick), 9 (second changedtick) and a big number of blank lines (normally printing messages and exiting in --cmd means that Vim will exit before starting drawing the screen, so all messages go to stderr, among other output *only* messages get to stderr and stdout, including alternate screen not being used (Vim tells terminal to use alternate screen by outputting special escape sequences, so it is “output to stderr or stdout”)).\n> \n>  \n> \n> \n> \n> If this cannot be fixed internally to not change b:changedtick, it should at least not trigger TextChangedI / TextChanged probably.\n> \n> \n> /cc @Shougo (because I've noticed this in the context of deoplete; Neovim is affected as well)"}}