Home Blog Do-it-yourself Repair for Fixer Scripts
 

Do-it-yourself Repair for Fixer Scripts

We just received a ticket that refactoring scripts with ISESteroids would mess up nicely formatted comment blocks.

As it turns out, there is a bug in one of the fixer scripts that might affect your scripts, too. So I’d like to explain what is wrong, and how you can immediately correct it yourself.

Refactoring Replaces TABs with Empty Space

When you run the refactor addon to bring your script in shape, the refactoring scripts – among many other things – look for illegal characters like typographic quotes, and replace them with the corrected string.

For some reason, the fixer script in charge treats ASCII code 9 as “illegal”, replacing it with an empty string.ASCII code 9 happens to be a TAB, so the fixer script is sucking out all TABs from your script.

This obviously can mess up formatting in some comment blocks, but may also affect other places in your script, like strings.

It did slip through quality control because the refactor addon also refreshes line indentation, so after the TABs are stolen, the new line indentation adds them where needed for indentation.

Repairing the Bug – and Understanding Refactoring

Fortunately, the entire refactoring addon is fully customizable and script based. So you can easily adjust the way how refactoring works, and correct this problem immediately. We’ll correct it anyway with the next update, but there is no need to wait.

While fixing the bug, you will also better understand how refactoring works in ISESteroids.

  1. Open the refactor addon, then click on ADVANCED.
  2. Expand the top section “Character Operations”.
  3. Right-click the fixer script “Illegal Characters”, and choose “Open Script”.
  4. In the fixer script, identify this line and remove it:
    '0009' = ''

As you can see, the fixer script for fixing illegal characters is a simple replacement table that you can adjust to your needs. Just don’t forget to SAVE your script when you made the changes.

From now on, TABs are no longer stolen from your scripts.

By the way, if you want to add TABs to a string or line, this wasn’t always easy with ISE because it treats TABs as trigger key for auto completion.

In ISESteroids, you can hold CTRL, then press TAB, to insert a real TAB anywhere.