Skip to content

[Advanced Paste] Add single-line paste formatting - #49647

Open
massimomazzariol wants to merge 2 commits into
microsoft:mainfrom
massimomazzariol:feature/advanced-paste-single-line
Open

[Advanced Paste] Add single-line paste formatting#49647
massimomazzariol wants to merge 2 commits into
microsoft:mainfrom
massimomazzariol:feature/advanced-paste-single-line

Conversation

@massimomazzariol

@massimomazzariol massimomazzariol commented Aug 3, 2026

Copy link
Copy Markdown

Summary of the Pull Request

Adds a new Paste as single line core action to Advanced Paste.

The action converts clipboard text to one line by replacing line-break sequences with a single space while preserving other text, including Unicode content. It is available from the Advanced Paste UI and can also be assigned an optional global shortcut from Settings.

Partially addresses #33109.

Scope

This PR intentionally implements only the single-line transformation requested in #33109.

Text case transformations requested in #38690 and #46354—including uppercase, lowercase, title case, sentence case, toggle case, and similar casing operations—remain out of scope for this PR and can be implemented separately.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Single-line transform

  • Adds PasteFormats.SingleLine as a non-AI, text-only core action.
  • Replaces CRLF, LF, CR, vertical tab, form feed, NEL, Unicode line separator, and Unicode paragraph separator sequences with one space.
  • Trims leading and trailing whitespace created around line breaks.
  • Preserves existing inline tabs and Unicode text.
  • Adds the action to the Advanced Paste UI.

Configurable direct shortcut

  • Adds an optional, unassigned-by-default shortcut in Advanced Paste Settings.
  • Persists the shortcut in settings.json under paste-as-single-line-hotkey.
  • Registers the shortcut through the native module interface.
  • Sends a dedicated IPC message to Advanced Paste and executes the new format without opening the popup.
  • Includes shortcut-conflict handling and telemetry consistent with the existing Markdown and JSON direct actions.

Explicitly not included

This PR does not add uppercase, lowercase, title case, sentence case, toggle case, camel case, or other case-conversion actions. Those requests remain tracked under the broader #33109 discussion, with #38690 and #46354 as related duplicates.

Validation Steps Performed

Automated

  • Advanced Paste unit tests passed, including new coverage for:
    • CRLF, LF, and CR
    • repeated line breaks
    • surrounding spaces and tabs
    • empty and whitespace-only input
    • Unicode separators
    • Unicode text preservation
    • null input
  • Settings unit tests: 178 passed, 0 failed.
  • Targeted Debug builds passed with 0 errors for:
    • PowerToys runner
    • PowerToys.Interop
    • Advanced Paste
    • AdvancedPasteModuleInterface
    • PowerToys Settings

Manual end-to-end

Validated with one coherent local Debug build:

  1. Opened PowerToys Settings and confirmed the new Paste as single line directly option is present.
  2. Assigned a custom shortcut.
  3. Copied multiline text and invoked the shortcut in Notepad.
  4. Confirmed the text was pasted as one line without opening the Advanced Paste popup.
  5. Restarted PowerToys and confirmed the shortcut remained saved and functional.
  6. Launched the same coherent build in a clean Windows Sandbox and confirmed PowerToys and the new Settings option loaded correctly.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions
github-actions Bot requested a review from chatasweetie August 3, 2026 22:38
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Thank you for contributing to PowerToys. We've detected that this PR might include a new or modified telemetry event. Please ensure the following before merging:

@massimomazzariol

Copy link
Copy Markdown
Author

@chatasweetie This PR does not introduce a new telemetry event name. It extends the existing AdvancedPaste_Settings event with the PasteSingleLineHotkey field and uses the existing AdvancedPaste_InvokeAdvancedPaste event with the new SingleLineDirect action value. Both events are already listed in DATA_AND_PRIVACY.md, and no clipboard or pasted text content is collected. Could you please confirm whether a DATA_AND_PRIVACY.md update or any additional telemetry registration step is required?

@moooyo

moooyo commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 49647 in repo microsoft/PowerToys

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preserve telemetry enum values

Severity: high

Assign explicit stable values and a new value for SingleLine.

Review validation: Fixed; Advanced Paste tests and modules pass on fork PR 211

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include shortcut in conflict warnings

Severity: medium

Include SingleLine in copy-shortcut conflict detection.

Review validation: Fixed and verified on fork PR 211

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collapse indented blank lines

Severity: medium

Keep horizontal whitespace inside repeated line-break matching.

Review validation: Fixed and verified on fork PR 211

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show shortcut on dashboard

Severity: low

Surface configured SingleLine shortcuts.

Review validation: Fixed and verified on fork PR 211

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevent regex backtracking

Severity: medium

Use RegexOptions.NonBacktracking.

Review validation: Fixed and verified on fork PR 211

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surface shortcut in OOBE

Severity: low

Add the optional localized shortcut summary.

Review validation: Fixed and verified on fork PR 211

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preserve core-action ordering

Severity: medium

Explicitly order core actions before optional actions.

Review validation: Fixed and verified on fork PR 211

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle missing upgrade setting

Severity: medium

Parse the new shortcut only when its JSON key exists.

Review validation: Fixed; 191 tests pass and XamlStyler/diff checks pass on fork PR 211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants