0

I kicked off a long-running script in ISE earlier, and started work on a second while it was running, keeping an eye on its progress in the console panel. I was copying a function call to another part of the second script when I typo'd and pushed Ctrl-C rather than Ctrl-V. Immediately, the executing script exited. It seems ISE interpretted it as a SIGTERM to the running script, even though I didn't have the console panel highlighted.
I can't see any options to disable this, but if this is intended behaviour then I find it unacceptable. I need to find a way to switch this off as I've lost about an hour's worth of work (the script has to run from start to end) through one accidental click that should have done nothing. Does anyone know if this is intended behaviour, or have I run into something else?

Gargravarr
  • 635
  • 2
  • 10
  • 18
  • Wow. Lot of work to avoid using 0,5sec to verify the button that one time in a day when you're unsure which button you're about to click. :-) This is definately by design. When you're not selecting text, CTRL+C will abort a script just like in a normal console. If you're running a long script I would suggest a separate powershell console/ISE. – Frode F. Sep 12 '16 at 17:17
  • @FrodeF. I would have no problem with Ctrl-C aborting the script *if I had the console panel selected*. In this case, I didn't - the cursor was in the text editor panel. Ctrl-C should not have been passed to the console. How easy is it to slip and hit C instead of V? Those typos should be harmless. And as I explained to briantist below, I am still working on this long-running script, hence running it within ISE. – Gargravarr Sep 13 '16 at 10:34
  • ISE is designed for development, PowerShell console for execution. While developing, you're using the script pane as the console, so making it cancel on CTRL+C while not selecting text is vital. If I had to click in the console I would probably not use ISE for developing anymore. Or I would try to override the hotkey with an ISE addon if possible. On a side-note, MS is planning to make PowerShell ISE support more Extensions (beginning the the ISE preview), so the option might be added to modify this. Post it on uservoice – Frode F. Sep 13 '16 at 10:38

1 Answers1

3

Workaround: File > New PowerShell Tab

That will create a new environment, which has the added benefit of letting you run the second script independently of the first.

But you might consider that ISE is better suited for development and testing of scripts, not so much for long running "production" processes while you also developing other scripts. I mean you can use it for that, but it's probably considered an edge use case.

You mentioned:

Creating the new tab does work, but it means I can't see the currently-executing script at a glance.

In that case, you can open a new console host (powershell.exe) and run your script outside of ISE (while continuing to develop it and save it in ISE). But it may still be hard to see unless you can move it to another monitor. Thoug hin that case, you could just open up a whole new ISE instance as well!

briantist
  • 45,546
  • 6
  • 82
  • 127
  • Thanks, this does seem to be a valid workaround. Thing is, I am still developing the long-running script, which is why I was running it within ISE at the time. In production, this script will run headless on our build servers. Creating the new tab does work, but it means I can't see the currently-executing script at a glance. Seems like a silly design decision to me to make Ctrl-C do that within the editor window. – Gargravarr Sep 12 '16 at 15:47
  • Both valid points. I just wish there was a simple option to say 'don't do this'. – Gargravarr Sep 12 '16 at 15:51
  • @Gargravarr unfortunately I don't think there is. In theory [PowerShell ISE Preview](https://blogs.msdn.microsoft.com/powershell/2016/01/20/introducing-the-windows-powershell-ise-preview/) is leading the way toward more frequent updates and fixes to ISE that aren't tied to major PowerShell version releases, but there hasn't been another version of this since it came out in January. – briantist Sep 12 '16 at 15:54