[PR #5096] [MERGED] Rework and simplify selection in TermControl #26102

Open
opened 2026-01-31 09:13:56 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5096
Author: @DHowett-MSFT
Created: 3/24/2020
Status: Merged
Merged: 3/25/2020
Merged by: @undefined

Base: masterHead: dev/duhowett/selection


📝 Commits (4)

  • 53080d3 Rework and simplify selection in TermControl
  • 975622d This test dies with TerminalCore's knowledge of CoS
  • 67092d4 PR feedback, comment
  • 9cfb0d5 Move CopyOnSelect to Control settings, complete the trifecta

📊 Changes

8 files changed (+41 additions, -121 deletions)

View changed files

📝 src/cascadia/TerminalControl/TermControl.cpp (+31 -29)
📝 src/cascadia/TerminalControl/TermControl.h (+7 -4)
📝 src/cascadia/TerminalCore/Terminal.cpp (+1 -5)
📝 src/cascadia/TerminalCore/Terminal.hpp (+0 -4)
📝 src/cascadia/TerminalCore/TerminalSelection.cpp (+0 -34)
📝 src/cascadia/TerminalSettings/IControlSettings.idl (+2 -0)
📝 src/cascadia/TerminalSettings/ICoreSettings.idl (+0 -1)
📝 src/cascadia/UnitTests_TerminalCore/SelectionTest.cpp (+0 -44)

📄 Description

This commit rewrites selection handling at the TermControl layer.
Previously, we were keeping track of a number of redundant variables
that were easy to get out of sync.

The new selection model is as follows:

  • A single left click will always begin a pending selection operation
  • A single left click will always clear a selection (#4477)
  • A double left click will always begin a word selection
  • A triple left click will always begin a line selection
  • A selection will only truly start when the cursor moves a quarter of
    the smallest dimension of a cell (usually its width) in any direction
    This eliminates the selection of a single cell on one click.
    (#4282, #5082)
  • We now keep track of whether the selection has been "copied", or
    "updated" since it was last copied. If an endpoint moves, it is
    updated. For copy-on-select, it is only copied if it's updated.
    (#4740)

Because of this, we can stop tracking the position of the focus-raising
click, and whether it was part of click-drag operation. All clicks can
become part of a click-drag operation if the user drags.

We can also eliminate the special handling of single cell selection at
the TerminalCore layer: since TermControl determines when to begin a
selection, TerminalCore no longer needs to know whether copy on select
is enabled or whether the user has started and then backtracked over a
single cell. This is now implicit in TermControl.

Fixes #5082; Fixes #4477


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/5096 **Author:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Created:** 3/24/2020 **Status:** ✅ Merged **Merged:** 3/25/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/duhowett/selection` --- ### 📝 Commits (4) - [`53080d3`](https://github.com/microsoft/terminal/commit/53080d304103e6d40af33938e1277d13e08e2dc9) Rework and simplify selection in TermControl - [`975622d`](https://github.com/microsoft/terminal/commit/975622db12849a72c045203842e9ae141a521a23) This test dies with TerminalCore's knowledge of CoS - [`67092d4`](https://github.com/microsoft/terminal/commit/67092d4512cbda638ebb98ec35098872f5e4bd50) PR feedback, comment - [`9cfb0d5`](https://github.com/microsoft/terminal/commit/9cfb0d5874f5a307a456ce10df573748c5ee556f) Move CopyOnSelect to Control settings, complete the trifecta ### 📊 Changes **8 files changed** (+41 additions, -121 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+31 -29) 📝 `src/cascadia/TerminalControl/TermControl.h` (+7 -4) 📝 `src/cascadia/TerminalCore/Terminal.cpp` (+1 -5) 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+0 -4) 📝 `src/cascadia/TerminalCore/TerminalSelection.cpp` (+0 -34) 📝 `src/cascadia/TerminalSettings/IControlSettings.idl` (+2 -0) 📝 `src/cascadia/TerminalSettings/ICoreSettings.idl` (+0 -1) 📝 `src/cascadia/UnitTests_TerminalCore/SelectionTest.cpp` (+0 -44) </details> ### 📄 Description This commit rewrites selection handling at the TermControl layer. Previously, we were keeping track of a number of redundant variables that were easy to get out of sync. The new selection model is as follows: * A single left click will always begin a _pending_ selection operation * A single left click will always clear a selection (#4477) * A double left click will always begin a word selection * A triple left click will always begin a line selection * A selection will only truly start when the cursor moves a quarter of the smallest dimension of a cell (usually its width) in any direction _This eliminates the selection of a single cell on one click._ (#4282, #5082) * We now keep track of whether the selection has been "copied", or "updated" since it was last copied. If an endpoint moves, it is updated. For copy-on-select, it is only copied if it's updated. (#4740) Because of this, we can stop tracking the position of the focus-raising click, and whether it was part of click-drag operation. All clicks can _become_ part of a click-drag operation if the user drags. We can also eliminate the special handling of single cell selection at the TerminalCore layer: since TermControl determines when to begin a selection, TerminalCore no longer needs to know whether copy on select is enabled _or_ whether the user has started and then backtracked over a single cell. This is now implicit in TermControl. Fixes #5082; Fixes #4477 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:13:56 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26102