Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero width control characters insert spaces with shell ex commands #4338

Closed
atommclain opened this issue Feb 24, 2016 · 4 comments · Fixed by #7979
Closed

Zero width control characters insert spaces with shell ex commands #4338

atommclain opened this issue Feb 24, 2016 · 4 comments · Fixed by #7979
Assignees
Labels
bug issues reporting wrong behavior tui
Milestone

Comments

@atommclain
Copy link

  • Neovim version: 9a3b7fa
  • Operating system: Gentoo 2.2
  • Terminal emulator: iTerm 2.1.1 (connected to remote system)

Discovered while researching #4142 and #2958

Running a shell command that echoes multiple bell symbols followed by text shifts text to the right.

Actual behaviour

Text preceded by zero width control bell character is shifted to the right.

Expected behaviour

Text should start in the first column.

Steps to reproduce

nvim -u NONE
:!echo -en '\x07\x07\x07\x07text'
// prints
    text
// instead of
text

vim 7.4.769 with same configuration exhibits expected behavior

@justinmk justinmk added the bug issues reporting wrong behavior label Feb 29, 2016
@justinmk justinmk self-assigned this Feb 29, 2016
justinmk added a commit to justinmk/neovim that referenced this issue Feb 29, 2016
TODO:

- [ ] tests
- [ ] handle tab chars "\t" neovim#2958
- [ ] handle bell chars "\x07" neovim#4338

If a binary or other output is read from :! the screen should not be
affected by accidental (or intentional) control chars.
Legacy Vim ":!" gets scrubbed (possibly by canonical ("cooked")
mode in mch_call_shell(), see settmode(TMODE_COOK)).

Expected behavior:

    :!echo -en '\x08'|cat -             " empty (except "Press ENTER")
    :!echo -en '\x08'                   " empty (except "Press ENTER")
    :!echo -en '\n'                     " extra line
    :echo system('echo -en ''\x08\n''') " ^H

    Issue neovim#4338
    :!echo -en '\x07\x07\x07\x07text'   " 'text' (not '    text')

    Issue neovim#2958 (Vim tputs()?)
    :!echo -e "1\t2\t3"                 " '1       2       3'

Closes neovim#4142
Closes neovim#2958
Closes neovim#4338
justinmk added a commit to justinmk/neovim that referenced this issue Apr 25, 2016
TODO:

- [ ] tests
- [ ] handle tab chars "\t" neovim#2958
- [ ] handle bell chars "\x07" neovim#4338

If a binary or other output is read from :! the screen should not be
affected by accidental (or intentional) control chars.
Legacy Vim ":!" gets scrubbed (possibly by canonical ("cooked")
mode in mch_call_shell(), see settmode(TMODE_COOK)).

Expected behavior:

    :!echo -en '\x08'|cat -             " empty (except "Press ENTER")
    :!echo -en '\x08'                   " empty (except "Press ENTER")
    :!echo -en '\n'                     " extra line
    :echo system('echo -en ''\x08\n''') " ^H

    Issue neovim#4338
    :!echo -en '\x07\x07\x07\x07text'   " 'text' (not '    text')

    Issue neovim#2958 (Vim tputs()?)
    :!echo -e "1\t2\t3"                 " '1       2       3'

Closes neovim#4142
Closes neovim#2958
Closes neovim#4338
@justinmk justinmk added environment user system environment (terminal, shell, tmux) tui and removed environment user system environment (terminal, shell, tmux) labels May 10, 2017
@justinmk justinmk added this to the 0.2.1 milestone May 10, 2017
@justinmk justinmk mentioned this issue May 10, 2017
25 tasks
@justinmk justinmk modified the milestones: 0.2.1, 0.2.2 Sep 16, 2017
@justinmk justinmk modified the milestones: 0.2.4, 0.2.3 Feb 6, 2018
@justinmk
Copy link
Member

justinmk commented Feb 6, 2018

#7844 outputs bell chars as ^G.

:!echo -en '\x07\x07\x07\x07text'
^G^G^G^Gtext

This is a design decision.

@justinmk justinmk closed this as completed Feb 6, 2018
justinmk added a commit to justinmk/neovim that referenced this issue Feb 7, 2018
justinmk added a commit to justinmk/neovim that referenced this issue Feb 7, 2018
justinmk added a commit to justinmk/neovim that referenced this issue Feb 7, 2018
@bfredl
Copy link
Member

bfredl commented Feb 7, 2018

The only design decision in #7488 is that we actually can determine what happens on each control char. We could easily change it emit bell, just add it to the list of bytes sent directly to msg_putc (just as ^M was changed)

@justinmk
Copy link
Member

justinmk commented Feb 7, 2018

Would that work for other control codes like colors? Currently colors are rendered as hl-SpecialChar. E.g. :!bash -i:

^[[0;30m^[[47mSSH^[[0m ^[[0;32mjustin@foo ^[[36m~/foo^[[0m^[[0;33m (test u=)^[[0m

@bfredl
Copy link
Member

bfredl commented Feb 7, 2018

It is a question of effort. Supporting bell is a trivial one-line change (message.c already supports it, we just need to ask it), so we could just as well do it now, while colors requires implementing or integrating a ANSI control code parser. And the such parser we should (eventually) integrate is :terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior tui
Projects
None yet
3 participants