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

Trim trailing whitespace option #11473

Merged
1 commit merged into from
Oct 28, 2021
Merged

Trim trailing whitespace option #11473

1 commit merged into from
Oct 28, 2021

Conversation

lovef
Copy link
Contributor

@lovef lovef commented Oct 10, 2021

Summary of the Pull Request

Opt in setting to trim trailing white space when pasting a text into the terminal

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Manually testing to paste text with and without trailing white spaces, with and without the option activated

@ghost ghost added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Oct 10, 2021
@lovef lovef force-pushed the trim-paste branch 2 times, most recently from 18bea3b to 6454f73 Compare October 12, 2021 16:23
@lhecker lhecker added the Needs-Second It's a PR that needs another sign-off label Oct 20, 2021
@zadjii-msft
Copy link
Member

@msftbot don't merge this before friday at 7pm

@ghost
Copy link

ghost commented Oct 26, 2021

Hello @zadjii-msft!

I think you told me that you want to delay the approval for a certain amount of time, but I am not confident that I have understood you correctly.

Please try rephrasing your instruction to me.

@zadjii-msft
Copy link
Member

@msftbot merge this friday at 7pm

@ghost
Copy link

ghost commented Oct 26, 2021

Hello @zadjii-msft!

I think you told me that you would like to reset custom auto-merge settings, but I am not confident that I have understood you correctly.

Please try rephrasing your instruction to me.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Thanks for whipping this up!

@@ -77,6 +77,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
INHERITABLE_SETTING(Model::GlobalAppSettings, winrt::Microsoft::Terminal::Control::CopyFormat, CopyFormatting, 0);
INHERITABLE_SETTING(Model::GlobalAppSettings, bool, WarnAboutLargePaste, true);
INHERITABLE_SETTING(Model::GlobalAppSettings, bool, WarnAboutMultiLinePaste, true);
INHERITABLE_SETTING(Model::GlobalAppSettings, bool, TrimPaste, false);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
INHERITABLE_SETTING(Model::GlobalAppSettings, bool, TrimPaste, false);
INHERITABLE_SETTING(Model::GlobalAppSettings, bool, TrimPaste, true);

Warm take: enable this by default. It's a sensible QoL improvement. I'm gonna give the team till Friday to NAK me on this one.

@lovef If it's not too much trouble, could you add this to defaults.json as well? (mostly just as reference):

"trimPaste": true,

(if you don't, the bot will still just merge this and I can take care of it in post ☺️)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problm, I added "trimPaste": true,. For it to make sense I also changed the default value in code as per your suggested change

Choose a reason for hiding this comment

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

Do I have to change this setting through the json file, as the doc suggests? I don't see a possibility do set it through the settings dialog.

I'm experiencing the behaviuor for a few days and I am surprised to see the changed behavour was introduced in October 21, already.

Copy link
Member

Choose a reason for hiding this comment

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

@bardware Which version are you using? The option should be right here:

image

On the "Interaction" page

if (pos == textView.npos)
{
// Text is all white space, set empty string
text = L"";
Copy link
Member

Choose a reason for hiding this comment

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

we can probably just bail all the way out of pasting, right? Or do we need to complete the event handler request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With a co_return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added co_return, seems to work as expected

@zadjii-msft zadjii-msft added the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 28, 2021
@ghost
Copy link

ghost commented Oct 28, 2021

Hello @zadjii-msft!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost
Copy link

ghost commented Feb 3, 2022

🎉Windows Terminal Preview v1.13.10336.0 has been released which incorporates this pull request.:tada:

Handy links:

@Hrxn
Copy link

Hrxn commented Sep 26, 2023

Question, what about leading whitespace?

Just this bit of powershell code as example:

function Send-Bytes {
	param(
		[string] $To,
		[string] $Arguments
	)

	begin {
		$startInfo = [System.Diagnostics.ProcessStartInfo]::new()
		$startInfo.RedirectStandardInput = $true
		$startInfo.FileName = $To
		$startInfo.Arguments = $Arguments

		$process = [System.Diagnostics.Process]::Start($startInfo)
		$inputStream = $process.StandardInput.BaseStream
	}

	process {
		$inputStream.WriteByte([byte]$_)
	}

	end {
		$inputStream.Flush()
		$inputStream.Close()

		$process.WaitForExit()
	}
}

It's indented with tabs, if I use pwsh.exe (i.e. the old ConHost) and do a multiline paste, the indentation is preserved - almost: the leading tabs are converted to spaces.

Pasting the same thing in Terminal trims all indentation.
I mean, it's not a functional change, but it looks a bit weird, to be honest.

Windows Terminal
Version: 1.17.11461.0

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a third option which replaces newlines by spaces when pasting content with multiple lines
6 participants