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

TM Terminal: backspace deletes whole word #392

Closed
mlocati opened this issue May 11, 2023 · 6 comments · Fixed by #619
Closed

TM Terminal: backspace deletes whole word #392

mlocati opened this issue May 11, 2023 · 6 comments · Fixed by #619
Labels
terminal The TM Terminal collection of features in CDT
Milestone

Comments

@mlocati
Copy link

mlocati commented May 11, 2023

I've installed Eclipse 2023-03 (Platform 4.27.0.v20230302-0300) and TM Terminal 11.1.0.202212091724.

In the Terminal view, when I hit the backspace character, the console deletes the whole word on the left instead of a single character.

This happens consistently on two Windows 11 PCs.

I've also tried installing Eclipse (Eclipse IDE for PHP Developers) in a Windows Sandbox: same error.

Here's a sample session:
terminal-backspace

@mlocati mlocati changed the title TM Terminal: backspace delete whole word TM Terminal: backspace deleted whole word May 11, 2023
@mlocati mlocati changed the title TM Terminal: backspace deleted whole word TM Terminal: backspace deletes whole word May 11, 2023
@jonahgraham
Copy link
Member

Thank you for the bug report. I can reproduce it.

Backspace is acting like Ctrl is being pressed. Perhaps we are sending the wrong keycode when backspace is being pressed.

Looking around it seems that we are probably sending Ctrl-H when backspace is sent. Looking at microsoft/terminal#755 microsoft/terminal#3935 and microsoft/vscode#98494 certainly makes it look like there is some work to do here.

@jonahgraham
Copy link
Member

A change like this:

diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java
index 759c16c..03f9d0d 100644
--- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java
+++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java
@@ -1173,6 +1173,13 @@
 				}
 			}
 
+			if (!ctrlKeyPressed && character == '\b') {
+				// \b is ^H which is interpreted by the console as Ctrl + Backspace
+				// which deletes a word. \b on its own should just delete a character
+				// so we send 0x7f to do that.
+				character = 0x7f;
+			}
+
 			//TODO: At this point, Ctrl+M sends the same as Ctrl+Shift+M .
 			//This is undesired. Fixing this here might make the special Ctrl+Shift+C
 			//handling unnecessary further up.

works - but I don't know if there should be more conditions on when we make the switch.

e.g. should it only apply when running on Windows host? Only when connected to cmd/ps? Something else?

@mlocati
Copy link
Author

mlocati commented May 12, 2023

Just a side note: with the current version of TM Terminal (11.1.0.202212091724), WLS isn't affected by this issue (that is, pressing the backspace key only deletes one character and not the whole word).

I've tried both executing bash.exe from already open "cmd.exe" and "pwsh.exe" TM Terminal views, and from a TM Terminal view opened directly with "C:\WINDOWS\System32\wsl.exe" (and argument "--distribution Ubuntu-22.04").

@jonahgraham
Copy link
Member

I tested my change on Windows host with cmd, git bash, wsl and ssh to a linux machine running bash and the behaviour of all of them worked well with the unconditional rewrite of \b -> 0x7f.

I need to test still Linux host (and maybe mac if I can get a hold of one) as well as connecting to serial connections and gdb CLI (linux only)

@jonahgraham jonahgraham added the terminal The TM Terminal collection of features in CDT label Sep 5, 2023
@mlocati
Copy link
Author

mlocati commented Sep 17, 2023

Any update on this? It's a really annoying bug...

jonahgraham added a commit to jonahgraham/cdt that referenced this issue Nov 14, 2023
Includes a new system property `org.eclipse.tm.terminal.control.convertBackspace`
to allow us to disable this new behaviour in the field if it turns out that
some terminal/host combination does not like this conversion.

Fixes eclipse-cdt#392
jonahgraham added a commit that referenced this issue Nov 14, 2023
Includes a new system property `org.eclipse.tm.terminal.control.convertBackspace`
to allow us to disable this new behaviour in the field if it turns out that
some terminal/host combination does not like this conversion.

Fixes #392
@jonahgraham jonahgraham added this to the 11.4.0 milestone Nov 14, 2023
@jonahgraham
Copy link
Member

I have added a fix for this to CDT 11.4.0 due for release in a few weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
terminal The TM Terminal collection of features in CDT
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants