Author Topic: PowerShell Dynamic Surround  (Read 283 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2618
  • Hero Points: 210
  • Text
PowerShell Dynamic Surround
« on: September 02, 2022, 11:42:40 pm »
The trick where you type
if ($thing) {
}
Then press down arrow to move code into the block isn't working in powerShell.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1776
  • Hero Points: 149
Re: PowerShell Dynamic Surround
« Reply #1 on: September 06, 2022, 01:41:04 pm »
It works for simple example scripts I've tried.  What's the code after the if statements when it fails for you?

For most languages, dynamic surround runs off statement tagging information.  PowerShell doesn't have a statement tagger, so dynamic surround will fall back on some simple defaults.  Which usually means pulling in code one line at a time. 

jporkkahtc

  • Senior Community Member
  • Posts: 2618
  • Hero Points: 210
  • Text
Re: PowerShell Dynamic Surround
« Reply #2 on: September 06, 2022, 07:44:14 pm »
See attached script.
1. Place cursor at end of line 9
2. <Enter>
3. Type "if<space>$true.
This is expanded to:
Code: [Select]
      if ($true) {
      }
4. Now <Down> - expecting surround, but I don't get it.


Note also that it indents more than it should.
If you add a new line after line 5 the indent is correct.


jporkkahtc

  • Senior Community Member
  • Posts: 2618
  • Hero Points: 210
  • Text
Re: PowerShell Dynamic Surround
« Reply #3 on: September 06, 2022, 07:53:29 pm »
Oh ... looks like I set "Dynamic Surround requires Shift+Cursor"!

But, there is still the indenting problem.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1776
  • Hero Points: 149
Re: PowerShell Dynamic Surround
« Reply #4 on: September 06, 2022, 10:29:55 pm »
Hmm, I don't see the indenting problem.  I'd bet I can reproduce it with your config.  Can you upload your user.cfg.xml file to support?   Just call the case PowerShellIndent.