maxbec / openHAB-Alignment-Tool

This extension adds support for formatting and indenting openHAB files. At the moment only the item-files are supported.
https://marketplace.visualstudio.com/items?itemName=max-beckenbauer.oh-alignment-tool
Eclipse Public License 2.0
21 stars 4 forks source link

"Reformat File" inserts new lines on each run #23

Closed DoganM95 closed 4 years ago

DoganM95 commented 4 years ago

Expected Behavior

Any additional click on "Reformat File" should produce the same result as the first click on it.

Current Behavior

Each click on context menu entry "Reformat File" inserts new empty lines between each existing line, stretching the whole code with empty lines.

Eyample: Starting point is the following code (.sitemap)

sitemap default label="My first sitemap"
 {
    // Syntax:
    // ElementType item=ItemName label="Description of the item shown on the webpage"
    Frame label="Testing"{
        Switch item=Presence_Brother_PT_P750W label="Description of the item shown on the webpage, here P750W"
        Default item=Chromecast_XE8005_Control icon=screen label="XE8005 Control"
    }
    Frame label="Working" {
        Slider item=Chromecast_XE8005_Volume icon=soundvolume label="XE8005 Volume"
    }
}

Second click on "Reformat File" produces the following output:

sitemap default label="My first sitemap"
 {

    // Syntax:

    // ElementType item=ItemName label="Description of the item shown on the webpage"

    Frame label="Testing"{

        Switch item=Presence_Brother_PT_P750W label="Description of the item shown on the webpage, here P750W"

        Default item=Chromecast_XE8005_Control icon=screen label="XE8005 Control"

    }

    Frame label="Working" {

        Slider item=Chromecast_XE8005_Volume icon=soundvolume label="XE8005 Volume"

    }

}

Third run produces:

sitemap default label="My first sitemap"
 {

    // Syntax:

    // ElementType item=ItemName label="Description of the item shown on the webpage"

    Frame label="Testing"{

        Switch item=Presence_Brother_PT_P750W label="Description of the item shown on the webpage, here P750W"

        Default item=Chromecast_XE8005_Control icon=screen label="XE8005 Control"

    }

    Frame label="Working" {

        Slider item=Chromecast_XE8005_Volume icon=soundvolume label="XE8005 Volume"

    }

}

And so on...

Possible Solution

Steps to Reproduce (for Bugs)

  1. Right Click -> Reformat File
  2. Right Click -> Reformat File (again) ... N. Right Click -> Reformat File (again)

Context

Your Environment

radokristof commented 4 years ago

I also have this problem.

maxbec commented 4 years ago

Should be fixed in the current beta version. Please test it. 80f4d2f14809e97df6573ac75435217718f14e3d

https://github.com/MaxBec/openHAB-Alignment-Tool/releases/tag/v2.0.0-beta.1