Skip to content

Allow pasting multiple lines in the Python Console (#9776)#9781

Merged
feerrenrut merged 1 commit into
nvaccess:masterfrom
accessolutions:i9776
Jul 1, 2019
Merged

Allow pasting multiple lines in the Python Console (#9776)#9781
feerrenrut merged 1 commit into
nvaccess:masterfrom
accessolutions:i9776

Conversation

@JulienCochuyt

@JulienCochuyt JulienCochuyt commented Jun 21, 2019

Copy link
Copy Markdown
Contributor

Link to issue number:

Fixes #9776

Summary of the issue:

It is currently impossible to paste more than one line in the python console. It would be handy if this could be possible, as it will make copying and testing code from the console easier.

Description of how this pull request fixes the issue:

Like on the standard Python Console, the input field remains single-line.
However, when pasting multiple lines from the clipboard, these are executed sequentially like if typed one by one.
Care is taken to consider the text already present in the input field and the position of the cursor to obtain the same result as pasting in a multi-line field.
Unlike on the standard Python Console, if a compilation error occurs on one line, pasting of the remaining lines stops to avoid execution of the remaining lines and ease reading of output error. In such a case, the original input text after the cursor is restored in the input field.
Nevertheless, as one would expect, pasting of multiple lines does not stop if the execution itself raises an exception.

Testing performed:

Ported from an add-on in use for a few months.
Probably better to further test live, though.

Known issues with pull request:

Change log entry:

In the Python Console, the input field now supports pasting multiple lines from the clipboard.

@LeonarddeR LeonarddeR left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This works as expected and is very well written, thank you!
I think the code is good as is, though I have one suggestion below.

Comment thread source/pythonConsole.py Outdated
Comment thread source/pythonConsole.py Outdated
JulienCochuyt added a commit to accessolutions/nvda that referenced this pull request Jun 21, 2019

@michaelDCurran michaelDCurran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are now conflicts with master due to the merging of some of your other prs for the python console.

@JulienCochuyt

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest master. Thank you for the merging of the other PRs.

@feerrenrut feerrenrut dismissed michaelDCurran’s stale review July 1, 2019 11:19

The PR has been rebased, it no longer conflicts.

@feerrenrut feerrenrut merged commit 80acce2 into nvaccess:master Jul 1, 2019
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone Jul 1, 2019
feerrenrut added a commit that referenced this pull request Jul 1, 2019
@JulienCochuyt JulienCochuyt deleted the i9776 branch July 2, 2019 06:20
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.

Allow pasting multiple lines in the Python Console

5 participants