{"action":"created","issue":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2850","repository_url":"https://api.github.com/repos/fish-shell/fish-shell","labels_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2850/labels{/name}","comments_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2850/comments","events_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2850/events","html_url":"https://github.com/fish-shell/fish-shell/issues/2850","id":143142784,"number":2850,"title":"Tab completion keeps including words previously typed on line","user":{"login":"cjbottaro","id":10292,"avatar_url":"https://avatars.githubusercontent.com/u/10292?v=3","gravatar_id":"","url":"https://api.github.com/users/cjbottaro","html_url":"https://github.com/cjbottaro","followers_url":"https://api.github.com/users/cjbottaro/followers","following_url":"https://api.github.com/users/cjbottaro/following{/other_user}","gists_url":"https://api.github.com/users/cjbottaro/gists{/gist_id}","starred_url":"https://api.github.com/users/cjbottaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjbottaro/subscriptions","organizations_url":"https://api.github.com/users/cjbottaro/orgs","repos_url":"https://api.github.com/users/cjbottaro/repos","events_url":"https://api.github.com/users/cjbottaro/events{/privacy}","received_events_url":"https://api.github.com/users/cjbottaro/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/fish-shell/fish-shell/labels/completions","name":"completions","color":"fad8c7"},{"url":"https://api.github.com/repos/fish-shell/fish-shell/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2016-03-24T03:53:39Z","updated_at":"2016-03-24T06:46:45Z","closed_at":"2016-03-24T06:24:53Z","body":"Custom completion always show words previously typed on the command line, instead of _just_ the words returned by the completion program.\r\n\r\n```\r\n$ hyperwave <tab>\r\nadhoc     deploy  hyperwave\\   pull  setup\r\naw-setup  help    play         scp   ssh\r\n\r\n$ hyperwave adhoc <tab>\r\n$ hyperwave adhoc hyperwave\\ adhoc\\\r\n```\r\n\r\nProbably easier to compare \"expected behavior\" and \"observed behavior\" below.\r\n\r\n### Reproduction Steps:\r\n\r\nHere's my custom completion setup...\r\n\r\n```\r\n#!/usr/bin/env fish\r\n\r\nset root (dirname (realpath (status --current-filename)))\r\n\r\nset -x PATH $root/bin $PATH\r\n# set -x HW_DEBUG 1\r\n\r\nset binary_suffix (uname -sm | sed -e 's/ /-/g')\r\nset completion_program \"$root/libexec/completion-$binary_suffix\"\r\n\r\nfunction _completion\r\n  set previous_words (commandline)\r\n\r\n  if eval \"echo \\\"$previous_words\\\" | grep \\\" \\\\\\$\\\"\"\r\n    set current \"\"\r\n  else\r\n    set current (echo $previous_words | awk '{ print $(NF) }')\r\n  end\r\n  set args -current \\\"$current\\\"\r\n  eval \"$root/libexec/completion-$binary_suffix\" '$args' $previous_words\r\nend\r\n\r\ncomplete -A -c hyperwave -x -a \"(_completion)\"\r\n```\r\n\r\n### Expected behavior:\r\n\r\n```\r\n$ hyperwave <tab>\r\nadhoc     deploy   pull  setup\r\naw-setup  help    play         scp   ssh\r\n\r\n$ hyperwave adhoc <tab>\r\n$ hyperwave adhoc \r\n```\r\n\r\nNotice `hyperwave\\ ` is not in the list of choices in the first example.\r\n\r\nNotice `hypewave\\  adhoc\\ ` has not been expanded onto the current command line in the second example.\r\n\r\n### Observed behavior:\r\n\r\n```\r\n$ hyperwave <tab>\r\nadhoc     deploy  hyperwave\\   pull  setup\r\naw-setup  help    play         scp   ssh\r\n\r\n$ hyperwave adhoc <tab>\r\n$ hyperwave adhoc hyperwave\\ adhoc\\\r\n```\r\n\r\nWhy is `hyperwave\\ ` offered as a completion option?  My completion program is not generating it.  It seems that Fish is just offering anything previously typed on the line, in addition to what my completion program is generating.\r\n\r\n### Additional information:\r\n\r\nfish, version 2.2.0\r\n\r\nDarwin haswell.local 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64 i386 MacBookPro11,2 Darwin\r\n\r\nbrew (Homebrew)\r\n\r\nTerminal or terminal emulator: iTerm2\r\n\r\n### Even more info\r\n\r\nThank you."},"comment":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/comments/200697236","html_url":"https://github.com/fish-shell/fish-shell/issues/2850#issuecomment-200697236","issue_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2850","id":200697236,"user":{"login":"zanchey","id":520741,"avatar_url":"https://avatars.githubusercontent.com/u/520741?v=3","gravatar_id":"","url":"https://api.github.com/users/zanchey","html_url":"https://github.com/zanchey","followers_url":"https://api.github.com/users/zanchey/followers","following_url":"https://api.github.com/users/zanchey/following{/other_user}","gists_url":"https://api.github.com/users/zanchey/gists{/gist_id}","starred_url":"https://api.github.com/users/zanchey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zanchey/subscriptions","organizations_url":"https://api.github.com/users/zanchey/orgs","repos_url":"https://api.github.com/users/zanchey/repos","events_url":"https://api.github.com/users/zanchey/events{/privacy}","received_events_url":"https://api.github.com/users/zanchey/received_events","type":"User","site_admin":false},"created_at":"2016-03-24T06:46:45Z","updated_at":"2016-03-24T06:46:45Z","body":"I think you can probably get away without a lot of that complexity, incidentally - try `if test -z (commandline -ct)` instead?"}}