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

Pasting multiline code conflicts with parentheses/brackets/brace-matching key handler #735

Closed
mklement0 opened this issue Jul 26, 2018 · 4 comments

Comments

@mklement0
Copy link

mklement0 commented Jul 26, 2018

Substantially revised after feedback from @SeeminglyScience.

Environment data

PS version: 6.1.0-preview.4
PSReadline version: 2.0.0-beta2
os: Linux vm-ub16 4.4.0-131-generic #157-Ubuntu SMP Thu Jul 12 15:51:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
PS file version: 

Steps to reproduce or exception report

If you have a key handler installed that inserts a matching parenthesis/bracket/brace, pasting multiline strings breaks:

{
 'hi'
}

results in:

PS>{}
PS>  'hi'
hi
PS> }
At line:1 char:1
+ }
+ ~
Unexpected token '}' in expression or statement.
+ CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken

It seems that pasting triggers the same behaviors as when typing, which is undesired.
That is, the { that is pasted on the first line causes a matching } to be inserted, which breaks the code.

@SeeminglyScience
Copy link
Contributor

SeeminglyScience commented Jul 27, 2018

Is it possible this is a profile difference?

The first line PS>{} makes me think you have this key handler from the sample profile registered.

Same thing happens with me in all platforms with that key handler registered.

@mklement0 mklement0 changed the title Pasting multiline code is broken on Unix-like platforms Pasting multiline code conflicts with parentheses/brackets/brace-matching key handler Jul 27, 2018
@mklement0
Copy link
Author

mklement0 commented Jul 27, 2018

@SeeminglyScience:

Great sleuthing, thank you.

Indeed, that was the problem and with that key handler in place it indeed also happens on Windows.
I've updated the original post.

@lzybkr:

Is there a way we can have our cake and eat it too?

I would't want to have to choose between the two features (pasting multiline snippets vs. paren/bracket/brace matching).

Or can you for technical reasons not tell the difference between code being typed vs. being pasted?

@SeeminglyScience
Copy link
Contributor

Or can you for technical reasons not tell the difference between code being typed vs. being _pasted?

That's right unfortunately, unless the paste is handled via a key handler. #579 is tracking that.

@mklement0
Copy link
Author

Thanks, @SeeminglyScience - I've added a comment there and I'm closing this.

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

No branches or pull requests

2 participants