Backward-delete-word (Ctrl+Backspace) does not follow wordDelimiters setting #6965

Closed
opened 2026-01-31 00:51:45 +00:00 by claunia · 5 comments
Owner

Originally created by @tonys1110 on GitHub (Mar 18, 2020).

Environment:
Microsoft Windows [Version 10.0.18362.720] (cmd.exe)
Windows Terminal (Preview) Version: 0.10.761.0

Steps to reproduce

  1. Open defaults.json and profiles.json and note the value of the wordDelimiters settings (" /\()"'-.,:;<>!@#$%^&*|+=[]{}?\u2502" in my/default case). Note the presence of ''.
  2. Open Windows Terminal running cmd.exe.
  3. Begin to cd to a path like "cd \Windows\System32" but do not hit ENTER.
  4. Hit Ctrl-Backspace.

Expected behavior

Only the previous "word" (System32) as-defined by the wordDelimiters setting.

Actual behavior

The entire path is deleted (\Windows\System32) instead of just the previous "word" (System32) as-defined by the wordDelimiters setting.

Originally created by @tonys1110 on GitHub (Mar 18, 2020). Environment: Microsoft Windows [Version 10.0.18362.720] (cmd.exe) Windows Terminal (Preview) Version: 0.10.761.0 # Steps to reproduce 1. Open defaults.json and profiles.json and note the value of the wordDelimiters settings (" /\\()\"'-.,:;<>~!@#$%^&*|+=[]{}~?\u2502" in my/default case). Note the presence of '\'. 2. Open Windows Terminal running cmd.exe. 3. Begin to cd to a path like "cd \Windows\System32" but do not hit ENTER. 4. Hit Ctrl-Backspace. # Expected behavior Only the previous "word" (System32) as-defined by the wordDelimiters setting. # Actual behavior The entire path is deleted (\Windows\System32) instead of just the previous "word" (System32) as-defined by the wordDelimiters setting.
claunia added the Resolution-ExternalNeeds-Tag-Fix labels 2026-01-31 00:51:45 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 18, 2020):

Unfortunately, backward-delete-word's behavior is specific to the shell you are using; CMD is no different. The wordDelimiters settings in Terminal configures what the terminal thinks is a word, and this has no bearing on what the shell thinks is a word. There's no way for a terminal to tell the shell what it thinks a word is, because the terminal has no idea what kind of process it is talking to.

This one is by-design.

If you want to change CMD's word delimiters, you can add a registry key to HKCU:\Console called WordDelimiters. Choose the String type and set it to whatever characters you want.

@DHowett-MSFT commented on GitHub (Mar 18, 2020): Unfortunately, `backward-delete-word`'s behavior is specific to the shell you are using; CMD is no different. The `wordDelimiters` settings in Terminal configures what the _terminal_ thinks is a word, and this has no bearing on what the _shell_ thinks is a word. There's no way for a terminal to tell the shell what it thinks a word is, because the terminal has no idea what kind of process it is talking to. This one is by-design. If you want to change CMD's word delimiters, you can add a registry key to `HKCU:\Console` called `WordDelimiters`. Choose the String type and set it to whatever characters you want.
Author
Owner

@eryksun commented on GitHub (Mar 18, 2020):

The above description is misleading. With cmd.exe and other classic shells (e.g. the REPL shell of python.exe), command-line editing is provided by the console session's cooked read, which is implemented by conhost.exe, not the shell. In contrast, PowerShell uses a low-level read and implements its own command-line editing via PSReadLine.

@eryksun commented on GitHub (Mar 18, 2020): The above description is misleading. With cmd.exe and other classic shells (e.g. the REPL shell of python.exe), command-line editing is provided by the console session's cooked read, which is implemented by conhost.exe, not the shell. In contrast, PowerShell uses a low-level read and implements its own command-line editing via PSReadLine.
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 18, 2020):

The above description is close, but leaves out a few minor details. Terminal treats the entire pseudoconsole as a remote that speaks VT, which still means that the undesirable line editing behaviors for processed input clients are "on the other side of the fence."

I appreciate you keeping me honest, though.

@DHowett-MSFT commented on GitHub (Mar 18, 2020): The above description is _close_, but leaves out a few minor details. Terminal treats the entire pseudoconsole as a remote that speaks VT, which still means that the undesirable line editing behaviors for processed input clients are "on the other side of the fence." I appreciate you keeping me honest, though.
Author
Owner

@eryksun commented on GitHub (Mar 19, 2020):

I appreciate you keeping me honest, though.

It's not directed at you per se. The concepts of shell, terminal, and session are jumbled up in Windows compared to Unix. In Unix, you run the terminal, which creates a session and starts a shell, and a terminal "cooked" read is still relatively raw. Classically in Windows, you run the shell, which allocates a console session and a terminal (console) window, if it doesn't inherit a console session, and a cooked read is well done, if not burnt to a crisp, by providing command editing, aliases, and history. With Windows Terminal, a further nuance has to be maintained. The user runs the terminal (wt.exe), which allocates a session (openconsole.exe, combined with condrv.sys in the kernel) and spawns the shell in that session. Then there's the double confusion that Windows has a graphical "session" with a controlling "terminal" (i.e. the "WinSta0" window station, with a display, input, and clipboard) and a "shell" (Explorer), so terminology gets reused depending on context.

@eryksun commented on GitHub (Mar 19, 2020): > I appreciate you keeping me honest, though. It's not directed at you per se. The concepts of shell, terminal, and session are jumbled up in Windows compared to Unix. In Unix, you run the terminal, which creates a session and starts a shell, and a terminal "cooked" read is still relatively raw. Classically in Windows, you run the shell, which allocates a console session and a terminal (console) window, if it doesn't inherit a console session, and a cooked read is well done, if not burnt to a crisp, by providing command editing, aliases, and history. With Windows Terminal, a further nuance has to be maintained. The user runs the terminal (wt.exe), which allocates a session (openconsole.exe, combined with condrv.sys in the kernel) and spawns the shell in that session. Then there's the double confusion that Windows has a graphical "session" with a controlling "terminal" (i.e. the "WinSta0" window station, with a display, input, and clipboard) and a "shell" (Explorer), so terminology gets reused depending on context.
Author
Owner

@tonys1110 commented on GitHub (Mar 19, 2020):

I don't exactly follow the lower level details described above, but when cmd.exe is run in conhost.exe in the classic way (Windows+R->cmd->ENTER OR Windows+R ->conhost->ENTER), it works in the way I'd expect/prefer, but when run in WT it does not.

Classic Cmd: "cd \Windows\System" + Ctrl+Bkspc = "cd \Windows" yay
WT: "cd \Windows\System" + Ctrl-Bkspc = "cd " boo

@tonys1110 commented on GitHub (Mar 19, 2020): I don't exactly follow the lower level details described above, but when cmd.exe is run in conhost.exe in the classic way (Windows+R->cmd->ENTER OR Windows+R ->conhost->ENTER), it works in the way I'd expect/prefer, but when run in WT it does not. Classic Cmd: "cd \Windows\System" + Ctrl+Bkspc = "cd \Windows\" yay WT: "cd \Windows\System" + Ctrl-Bkspc = "cd " boo
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#6965