Commit graph

21 commits

Author SHA1 Message Date
Eric Freese
c1910348c7 Implement completion suggestion strategy (#111)
Based on https://github.com/Valodim/zsh-capture-completion

`zpty -r` with a pattern seems to have some funky behavior on older
versions, giving unpredictable results

Don't use `-s` option to `zmodload`. It is not available in zsh versions
older than 5.3

If running in sync mode and a completion takes a long time, the user can
^C out of it. We need to use `always` in the strategy function or the
pty will not be destroyed in this case and the next time we go to create
it, it will fail, making the shell unusable.

User can have many different completion styles set that will modify what
they've already typed. These styles will result in suggestions that
don't match what the user has already typed. We try our best to unset
some of the more problematic ones, but add some code to fetch to
invalidate suggestions that don't match what the user's already typed.
2019-04-11 09:53:55 -06:00
Eric Freese
e405afab29 Refactor async mode to no longer use zpty
See technique used in `fast-syntax-highlighting`:
- ca2e18bbc9
- http://www.zsh.org/mla/users/2018/msg00424.html

Also see http://www.zsh.org/mla/users/2018/msg00432.html

In async response handler:
- We only want to read data in case of POLLIN or POLLHUP. Not POLLNVAL
  or select error.
- We always want to remove the handler, so it doesn't get called in an
  infinite loop when error is nval or err.

There is an upstream bug that prevents ctrl-c from resetting the prompt
immediately after a suggestion has been fetched asynchronously. A patch
has been submitted, but a workaround for now is to add `command true`
after the exec.

See https://github.com/zsh-users/zsh-autosuggestions/issues/364
2019-04-09 14:45:22 -06:00
Eric Freese
a78ea16c50 Support fallback strategies by setting array in config 2018-11-24 09:56:30 -07:00
Eric Freese
a1babef972 Revert "Simplify escaping of pattern and fix match_prev_cmd strategy"
This reverts commit 7f8ff2867c.
2017-12-06 08:08:53 -07:00
Stefan Siegel
7f8ff2867c Simplify escaping of pattern and fix match_prev_cmd strategy
Maybe this is also a fix for #247, #248 and #258. Supersedes #267.

Testcase:
Using match_prev_cmd strategy and with these lines in history:
echo '1^'
echo '2^'
echo '1^'

type:
echo       (unexpected suggestion echo '1^' instead of echo '2^')
echo '1^1  (wrong suggestion echo '1^1echo '1^')
echo '1^#  (error "bad math expression")
2017-09-10 04:35:19 +02:00
Eric Freese
39762ecd97 Set up circle ci 2017-02-26 14:26:41 -07:00
Eric Freese
dcce973287 Remove support for long-deprecated options
These options have been deprecated for over a year.
2017-02-17 18:45:46 -07:00
Eric Freese
ed8056c5e8 Lots of async changes 2017-02-16 19:19:30 -07:00
Eric Freese
78ba07179a Add feature detection
Checks whether `zpty` gives a file descriptor, which was not the case in
older versions of zsh.

Based on a4b2f81c96/async.zsh (L395-L401)
2017-01-26 16:40:34 -07:00
Eric Freese
ab8f295225 First pass at async functionality 2017-01-24 19:45:11 -07:00
Eric Freese
4850119887 Add separate test task for RSpec 2017-01-19 22:38:19 -07:00
Eric Freese
4a2d9f9049 Fix Makefile to not create symbolic link after PR #156 was merged 2016-05-28 08:26:24 -06:00
Eric Freese
c477db2696 Remove unused test variables from Makefile 2016-04-15 13:41:41 -06:00
Eric Freese
a28e72e84a Test Runner now supports running specific tests and choosing zsh bin 2016-03-15 09:04:17 -06:00
Eric Freese
e5cdbb6c33 Lots of test cleanup. 2016-03-14 16:51:27 -06:00
Geza Lore
976acc708c Fix default suggestion strategy and add testing 2016-03-14 16:51:20 -06:00
Eric Freese
83f78d0760 Add suggestion "strategy" concept with default strategy 2016-03-14 16:51:20 -06:00
Eric Freese
abe577d519 Fix build 2016-02-13 14:13:21 -07:00
Eric Freese
03bd381112 Add .plugin file and installation instructions for Oh My Zsh (#104). 2016-02-07 15:35:54 -07:00
Eric Freese
00bd0e9125 Use add-zsh-hook to remove need to call autosuggest_start. 2016-02-07 15:35:43 -07:00
Eric Freese
775dd20706 Rewrite 2016-02-06 21:05:02 -07:00