Script Editor Paste->Execute bug in Maya 2017 and 2018

Script Editor Paste->Execute bug in Maya 2017 and 2018

FirespriteNate
Advocate Advocate
3,393 Views
9 Replies
Message 1 of 10

Script Editor Paste->Execute bug in Maya 2017 and 2018

FirespriteNate
Advocate
Advocate

I've noticed an annoying new bug that appeared in 2017 and it's still present in 2018.

 

Whenever I press CTRL-V to paste some text into any of the Script Editor Input panels Maya immediately executes the entire body of script inside that panel. As you can imagine this is extremely irritating and often dangerous.

It doesn't happen every time I press CTRL-V, usually only after the Script Input Panel receives focus after something else (which it always does if I switch to notepad++ or a web page to copy something and back again to paste it into the Script Editor)

This never happened in Maya 2016.5 or below.

 

Anyone know what is causing this and if there's a valid workaround?

Thanks

 

Hi @FirespriteNate your title 'Script Editor - Paste->Execute bug' was edited for clarity by @sean.heasley

0 Likes
Accepted solutions (2)
3,394 Views
9 Replies
Replies (9)
Message 2 of 10

sean.heasley
Alumni
Alumni

Hi @FirespriteNate and welcome!

 

I just did a quick attempt by copying some code out of notepad++ and pasting it in the MEL and Python script editor and it isn't automatically running like yours is.

 

Could you possibly post a video of your issue so I can see it happening in real time?

If you need a video capturing program, Screencast is a great option that we use here at Autodesk.

 

 

Let me know if anything changes!

0 Likes
Message 3 of 10

FirespriteNate
Advocate
Advocate
Accepted solution

Hey Sean, thanks for the reply. This issue is weirdly sporadic and, no matter what I try, I find it extremely hard to make it happen when I'm deliberately trying to. However, while I was trying to make it happen repeatedly and predicable for you I came to the conclusion that it may actually be my own fault. Smiley Embarassed

I'm not entirely convinced, but it seems that it only happens when I am typing and trying to paste too fast, i.e. when I paste something immediately after pressing enter to drop to a new line. It could be that I'm smashing down on the CTRL key (in readiness to hit V to paste) before I've completely finished releasing the Enter key. The script Editor is registering this as CTRL-Enter and executing everything.

 

What's puzzling is that I'd NEVER seen this happen before and I've been scripting in the Script Editor since before Maya 4.5. Maybe Maya 2017 changed how the keyboard interrupts are handled or something? or maybe CTRL-Enter simply worked differently on previous versions..? (I always use keypad Enter to execute)

 

I'm going to keep my eye on it but it could just be down to me typing too fast... which would also explain why nobody else has mentioned it yet...

Cheers

 

 

 

0 Likes
Message 4 of 10

sean.heasley
Alumni
Alumni

Hi @FirespriteNate

 

No worries! User errors happen all the time, myself included Smiley Tongue

 

I did just do a quick check on Maya 2017 and 2018 and yes if you hit ctrl enter it runs all the code that has been pasted so it's most likely the reason that's been happening to you.

 

It's definitely worth keeping an eye on though and thanks for bringing it to my attention!

0 Likes
Message 5 of 10

sean.heasley
Alumni
Alumni

Hi @FirespriteNate

 

I'm just checking in again to see if you need more help with this. While it looks like we both believe that the issue was happening because of accidentally hitting CTRL+Enter, I wanted to check in to see if the issue has occurred at all since without hitting those keys?

If your issue is resolved, please click Accept as Solution on the posts that helped you so others in the community can find them easily.

0 Likes
Message 6 of 10

Anonymous
Not applicable

Hi,
Just thought id mention as I'm having the same issue.
Same as above as it seems quite random, but it definitely happens when using Ctrl+V

Have noticed it enough times to make sure its not human error

Using maya2017 p5 on linux, copying text from pycharm 2017.1.3

0 Likes
Message 7 of 10

Anonymous
Not applicable

Also, if it helps,

Seems the Ctrl+v issue will first run all the code, then paste the copied code in, then clear the script editor sometimes.

I was able to tell this as when pasting, it ran my already existent code with no errors (as the code was ok), then pasted the copied code but didn't run (as it has errors in the pasted code but no errors were reported in maya/no output text) . Then clears out the script editor, as using edit>undo will show your original code + the pasted code

Message 8 of 10

flavatron
Explorer
Explorer

Hello @sean.heasley !

 

Hoping this has been looked into a little more as I am still having the same issue as @FirespriteNate in Maya 2020.2.

 

In a python script editor tab, if I Ctrl-V code it randomly executes the entire contents of that tab.  Doesn't happen every time.  I am for certain I'm not hitting Ctrl-Enter since those keys are no where close to each other on the keyboard. 

 

Not sure why this issue is marked and resolved, it's definitely still causing me a lot of frustration.

 

Appreciate any help you can provide!

Message 9 of 10

FirespriteNate
Advocate
Advocate
Accepted solution

I don't believe this is resolved either, but I don't think Autodesk will ever bother to look into or "fix" this as it's technically not a bug or an error, it's simply a feature they added years ago, thinking it would be super useful and not realising it actually causes a potentially catastrophic glitch for a tiny handful of users due to what is simply (in Autodesk's infallible opinion) "user error".

 

I have no way to verify this but I am 100% convinced it is due to them adding the shortcut "CTRL-Return" to execute the script content which didn't work before 2016ish.. I can only assume that during the rare occasions when you guys are seeing it while only pressing CTRL-V it is because maybe the copied text has some kind of hard carriage return code embedded in it so it's executed during paste? not sure if this is even possible though, but it's the only thing I can think of.

 

I'm now using 2020 (and have used every version extensively since this appeared in 16/17) and every version is affected in the same way.

 

I haven't eradicated the problem, but I have "solved" it in my own unique way... at the top line of EVERY Script Editor panel I now create, Python or (very rarely) MEL I type:

 

THANKS AUTODESK

 

and then if I ever accidentally trigger the glitch I don't execute a ton of catastrophically harmful code, but instead just generate an error:

 

# Error: invalid syntax
#   File "<maya console>", line 2
#     THANKS AUTODESK
#            ^
# SyntaxError: invalid syntax # 

 

and none of my Script Editor code is cleared either.

Message 10 of 10

flavatron
Explorer
Explorer

@FirespriteNate That's an ingenious hack to prevent execution 🙂

 

Yeah as you said I never encountered this problem prior to 2017, something in the way keys are being detected may be the culprit.  I thought that prior Ctrl-Enter only executed the SELECTED code, not all the code in the tab.  I could be wrong though, I don't remember off the top of my head.

 

Would be nice to have some control as to what the behavior is.