Commit Graph

54 Commits (db290c518b600eedbb7af818ce19c5e7f106ceb7)

Author SHA1 Message Date
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
6 years ago
Eric Freese e937e89267 Respect user's set options when running original widget
Fixes GitHub #379
7 years ago
Eric Freese 41657e3565 Revert async process substitution & completion strategy
They're not quite ready. Keep them on a feature branch for now.
7 years ago
Eric Nielsen e61442161e Don't overwrite config with default values
otherwise users are obliged to set the config values *after* sourcing
the plugin. They're not able to do it before. Also, re-sourcing the
plugin will reset the values to the defaults again.

See zimfw/zimfw#301

Fixes #335
7 years ago
Eric Freese 4b28d92e01 Add `after_sourcing` hook for tests
Is executed immediately after sourcing the plugin
7 years ago
Eric Freese d7171232c3 Merge branch 'develop' into features/completion-suggestions 7 years ago
Eric Freese 9cb0101512 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
7 years ago
Eric Freese bcbdad83e9 Support fallback strategies by setting array in config 7 years ago
Eric Freese 973205005c Add spec for `completion` strategy 7 years ago
Eric Freese 7d19f8f9b2 Rename default spec to history spec 7 years ago
Eric Freese 3dbd9afaec Fix completion strategy killing other pty's
Only a problem in synchronous mode
7 years ago
Eric Freese f63afd5969 Fix async pty name option spec 7 years ago
Eric Freese 5549b68e6e Async is less reliable in zsh versions < 5.0.8
`stty` occasionally hangs (always in CircleCI) inside the async pty.

Disable the tests for now until we can figure out and fix/workaround
this issue.
7 years ago
Eric Freese 63789e96b5 Fix handling of newline + carriage return in async pty (#333) 7 years ago
Eric Freese df5fb858aa Destroy old pty even if it's no longer running (#249)
For unknown reasons, the pty will occasionally quit running. In these
cases, we still want to remove it so that a fresh one can be created. We
don't actually need this check because error messages from `zle` and
`zpty` are redirected to /dev/null.

One sure way to kill all currently running pty's is to run `exit` in a
subshell. Even without zsh-autosuggestions loaded, the following works:

    % zmodload zsh/zpty
    % zpty -b foo cat
    % zpty -b bar cat
    % zpty
    (31689) bar: cat
    (31666) foo: cat
    % $(exit)
    % zpty
    (finished) bar: cat
    (finished) foo: cat
7 years ago
Eric Freese 726bc4eb5c Create general spec for async behavior 7 years ago
Harm te Hennepe 59c72c6805 Don't break kill ring rotation 7 years ago
Eric Freese 393f7b8bb9 Fix vi-mode partial-accept
Issue #188. PR #324.

Thanks to @toadjaune and @IngoHeimbach.
7 years ago
Eric Freese 42f5a06f7f Need to reset the POSTDISPLAY if exiting early
Specific case where this matters is following:

Be in vi insert mode with some text in the buffer and the cursor at the
end of the buffer. Press `esc` to trigger `vi-cmd-mode widget`, then
before the cursor moves (KEYTIMEOUT), press `h` to trigger
`vi-backward-char` widget. When `vi-cmd-mode` original widget exits,
KEYS_QUEUED_COUNT will be non-zero and the suggestion will be lost.
7 years ago
Eric Freese 51fef255da Add method to connect terminal to tmux session during tests
Useful with `binding.pry` to inspect behavior of tests.
7 years ago
Eric Freese 3136700ccf Don't fetch suggestions after [up,down]-line-or-beginning-search
These widgets rely on `$LASTWIDGET` being set to restore the cursor
position. When asynchronous suggestions are enabled, and the widget
triggers a suggestion to be fetched, `autosuggest-suggest` will be
called and $LASTWIDGET will be set to it.
7 years ago
Kaleb Elwert 940e10a691 Fix conditionals to use [[ and (( rather than [
This fixes a small issue in src/widgets.zsh which makes it so if you
alias [ to g[ (as is done in prezto if the gnu-utility module is loaded)
autosuggestions would fail.

The documentation for GNU test mentions that -o and -a should be avoided
if possible because it's not very clear. Also, with zsh and [[ -o
actually tests if an option is set, which makes this option even more
confusing.
8 years ago
Eric Freese 218acf2fbe Merge branch 'fixes/match_prev_cmd_special_chars' into develop 8 years ago
Eric Freese 0681a1c121 Remove flaky test that doesn't really matter that much
Seems like this would happen on some machines but not on others. Not
sure exactly what's going on, but this is such an edge case I'm just
going to remove the test.
8 years ago
Eric Freese 9e110406fa Add test for special characters with match_prev_cmd strategy
Github #247 and #258
8 years ago
Eric Freese 83129dd796 Make asynchronous suggestions disabled by default
While they are still experimental
8 years ago
Eric Freese a2f0ffb122 Enabling suggestions should not fetch a suggestion if buffer is empty 8 years ago
Eric Freese 7d4a1d9a4a Add enable/disable/toggle widgets to disable suggestion functionality
[GitHub #219]

Intended to be helpful for folks using bracketed-paste-magic and other
widgets that use `zle -U`.
8 years ago
Eric Freese e1959d0f61 Put in a general fix for #219 - Handling input from `zle -U`
Depends on patch to ZSH from workers/40702:

  http://www.zsh.org/mla/workers/2017/msg00414.html
8 years ago
Eric Freese c52c428793 Fix issues with widgets wrapped by other plugins
Puts in a better fix for #126 and related issues.
8 years ago
Eric Freese ea505b01e5 Add a spec for unlisted widgets fetching a new suggestion 8 years ago
Eric Freese 502fb4a174 Make tmux_socket_name public so you can access easily from binding.pry
Can attach while tests are stopped with `tmux -L <socket_name> attach`
8 years ago
Eric Freese 468b7403e9 Test should be passing block to RSpec wait_for
Fixes flaky test
8 years ago
Eric Freese c9a51e0c4c Handle dashes at the beginning of commands 8 years ago
Eric Freese 2cd99e64b7 Add a test for modifying widget list vars after sourcing plugin 8 years ago
Eric Freese c70d685d15 Clean up widget list spec 8 years ago
Eric Freese 255359dbb8 Use `+=` to be a bit more true to the spec language 8 years ago
Eric Freese 938144530c Fix tests 8 years ago
Eric Freese c4bfd8e2c6 Need to prevent zpty feature detection from HUPing existing zptys 8 years ago
Eric Freese c959408305 Only wait a max of 2 seconds for content to match after clearing screen 8 years ago
Eric Freese ed8056c5e8 Lots of async changes 8 years ago
Eric Freese 64e7ec5bf8 Rename internal term session method 8 years ago
Eric Freese 98f926d53d Clean up TerminalSession constructor a bit 8 years ago
Eric Freese 51e8755634 TerminalSession methods return self to support chaining 8 years ago
Eric Freese 5151adfe40 Make TerminalSession#clear block until the screen is cleared 8 years ago
Eric Freese c3425870f1 Wait for the terminal.clear to go through before continuing
Prevents some flakiness in tests
8 years ago
Eric Freese 89dd69d517 Add pry gem for debugging support 8 years ago
Eric Freese 2dbd261989 Allow configuring of zsh binary to run integration tests against 8 years ago
Eric Freese 0305908adf Revert `fc` usage in calculating suggestion
As far as I know, `fc` makes it impossible to tell whether history items
used an actual newline character or the string "\n". Pulling from the
`$history` array gives a more accurate representation of the actual
command that was run.
8 years ago
Eric Freese 8e06a54b1c Add test for string with "\n" in it 8 years ago