Skip to content

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

Closed

Description

Substantially revised after feedback from Patrick Meinecke (@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.

Activity

  1. SeeminglyScience commented on Jul 27, 2018

    @SeeminglyScience
    Collaborator

    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.

  2. changed the title [-]Pasting multiline code is broken on Unix-like platforms[/-] [+]Pasting multiline code conflicts with parentheses/brackets/brace-matching key handler[/+] on Jul 27, 2018
  3. mklement0 commented on Jul 27, 2018

    @mklement0
    Author

    Patrick Meinecke (@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.

    Jason Shirk (@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?

  4. SeeminglyScience commented on Jul 27, 2018

    @SeeminglyScience
    Collaborator

    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.

  5. mklement0 commented on Jul 27, 2018

    @mklement0
    Author

    Thanks, Patrick Meinecke (@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions