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

ESC is sometimes dropped #1017

Closed
cqexbesd opened this issue Jan 30, 2023 · 6 comments · Fixed by #1031
Closed

ESC is sometimes dropped #1017

cqexbesd opened this issue Jan 30, 2023 · 6 comments · Fixed by #1031
Labels
blocker:office Bug reported by my colleges, and hence should be fixed ASAP. :) bug Something isn't working

Comments

@cqexbesd
Copy link
Contributor

Contour Terminal version

0.3.10-master-2532adfe

Installer source

Github: source code cloned

Operating System

Arch Linux as of approx a week ago

Architecture

x86-64

Other Software

NVIM v0.8.2

Steps to reproduce

In a vi session, occasionally, a press of ESC is missed. It only happens occasionally and I don't know how to reliably trigger it. It may not be related to being in vi but of course that's when I would notice missing ESC.

With some debug tags on I see:

[2023-01-31 00:19:38.395865] [gui.input] Character press event received: Shift }
[2023-01-31 00:19:38.395922] [pty.output] Sending bytes: "}"
[2023-01-31 00:19:38.763825] [gui.input] Character press event received: None \e
[2023-01-31 00:19:39.267889] [pty.output] Sending bytes: "\eOA"
[2023-01-31 00:19:39.267916] [gui.input] key press: None UpArrow
[2023-01-31 00:19:39.467887] [pty.output] Sending bytes: "\eOC"
[2023-01-31 00:19:39.467911] [gui.input] key press: None RightArrow

So it looks like the ESC is missed being sent to the pty and from then on the input and output log messages are in reverse - i.e it sends my input before it receives it.

Expected Behavior

Every press to be sent

Actual Behavior

ESC was swallowed

Additional notes

No response

@cqexbesd cqexbesd added the bug Something isn't working label Jan 30, 2023
@christianparpart christianparpart added the blocker:office Bug reported by my colleges, and hence should be fixed ASAP. :) label Jan 31, 2023
@christianparpart
Copy link
Member

Good morning. I wonder if that is really a thing or if CSIu us the only way to fix this. 🤔

@cqexbesd
Copy link
Contributor Author

cqexbesd commented Feb 3, 2023

I don't know if this helps but I just hit it in the shell with vt.input debugging on as well.

[2023-02-03 17:58:15.874057] [vt.input] Sending None UpArrow.
[2023-02-03 17:58:15.875447] [pty.output] Sending bytes: "\e[A"
[2023-02-03 17:58:15.875472] [gui.input] Key press event received: None UpArrow
[2023-02-03 17:58:16.145956] [gui.input] Character press event received: None \e
[2023-02-03 17:58:16.146003] [vt.input] Clearing selection.
[2023-02-03 17:58:16.388653] [gui.input] Input not handled for mods Shift key 0x1000020
[2023-02-03 17:58:16.602237] [gui.input] Character press event received: Shift $
[2023-02-03 17:58:16.602426] [pty.output] Sending bytes: "$"
[2023-02-03 17:58:17.665933] [gui.input] Character press event received: None \x08

Based on timing of log messages, is the ESC interpreted as "clearing selection" and not a regular key press? I'm not sure what the selection was - I wasn't aware of having anything selected at either time but maybe I mis-clicked at some point and had selected something? I will watch out for that in future to see if this is what is happening - I don't know if there is a debug flag to record such events?

@cqexbesd
Copy link
Contributor Author

cqexbesd commented Feb 9, 2023

Just hit it again and there was certainly nothing selected that was visible, but there would have been something selected in the shell before I entered vi. If this is the cause then I shouldn't hit it again (assuming no more selection) whilst I am in vi - and that seems to be the case.

So that probably means this isn't a bug but a design flaw - in so far as the code is probably doing what was planned but the user experience seems sub par.

It seems like selecting with the mouse effectively puts the terminal into a special mode that you need to use ESC to get out of, but everything else works as normal. I think there should be no special mode and there can be a key combo to deselect if you want - which you could map to ESC if you really wanted to but is probably better using ctrl-shift-something like the other defaults.

@cqexbesd
Copy link
Contributor Author

cqexbesd commented Feb 9, 2023

I have now removed the mapping for ESC to clear selection (which is the default) and I see no more lost ESCs so I think this was the problem. So I would say ESC shouldn't be mapped by default to anything, given it is captured even if the selected item has scrolled off long ago,

@christianparpart
Copy link
Member

christianparpart commented Feb 13, 2023

loool. Thanks @cqexbesd for the patience and finding out yourself. You would have made me going crazy trying to reproduce this (while not using the mouse) :-D

So I guess we can close it then?

And, this default key mapping of ESC clearing the selection in case something was selected, to me personally, still makes sense to keep as default.

Hm, wait, maybe I can generally improve on the Select mode in the config. 🤔

@cqexbesd
Copy link
Contributor Author

I don't know the best solution but I think something should change - because it took me so long to work out what was going on and it was very annoying. Obviously it will only affect mouse users but I remember computers before mice and I think mice are great :-P

Probably the key confusing thing is that if the selected text is no longer on the screen, perhaps hidden by an editor, or just scrolled off, then there is no sign as to what ESC has done. If your workflow involves frequent copies though there will often be something selected and in previous terminal emulators it made no difference - mostly because the terminal was (probably) unaware of anything selected by mouse - the mouse did mouse things and the keyboard did text things. Contour merges these two worlds.

christianparpart added a commit that referenced this issue Feb 14, 2023
Fixes mouse selection to only be initiated if actually meant to, i.e. in alt screen mode only if bypass-modifier was pressed (#1017).

Signed-off-by: Christian Parpart <christian@parpart.family>
christianparpart added a commit that referenced this issue Feb 14, 2023
Fixes mouse selection to only be initiated if actually meant to, i.e. in alt screen mode only if bypass-modifier was pressed (#1017).

Signed-off-by: Christian Parpart <christian@parpart.family>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker:office Bug reported by my colleges, and hence should be fixed ASAP. :) bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants