Sublime Forum

PowerShell reindent problem with c#

#1

With Powershell I have this code:

Function Get-ForegroundWindow {
  Add-Type @"
  using System; using System.Runtime.InteropServices; public class ClassGetForegroundWindow {
    [DllImport("user32.dll")]
    public static extern IntPtr GetForegroundWindow();
  }
"@
  return [ClassGetForegroundWindow]::GetForegroundWindow()
}

Get-ForegroundWindow

After reindenting it it appears to be:

Function Get-ForegroundWindow {
  Add-Type @"
  using System; using System.Runtime.InteropServices; public class ClassGetForegroundWindow {
    [DllImport("user32.dll")]
    public static extern IntPtr GetForegroundWindow();
  }
  "@
  return [ClassGetForegroundWindow]::GetForegroundWindow()
}

Get-ForegroundWindow

This then fails to run as the "@ is indented when it shouldn’t.

Does anyone know a way around this?

0 Likes

#2

Let’s continue this discussion at https://github.com/SublimeText/PowerShell/issues/168

1 Like