mogulargmbh / m-formatter

23 stars 3 forks source link

Pasting query creates increasing number of white spaces #17

Closed PBIQueryous closed 1 year ago

PBIQueryous commented 1 year ago

Description Using the webformatter - each time the formatter is ran, pasting the formatted code generates an ever increasing number of whites spaces creating many "empty" lines between steps and lines of code. The effect does not reflect the visible output in the web formatter. EDIT: after testing, it appears the bug does not occur on the first formatted instance, but only subsuquent formatting instances

Power Query- / M-Code The code you wanted to formatted but that triggered your bug i.e. was not formatted properly.

let fn = (Start_Year as number, End_Year as number) => let monthList = List.Generate(() => #date(StartYear, 1, 1), // Starting value
each
<= #date(EndYear, 12, 31), // Create only when <= 31 dec 2024
each Date.AddMonths(
, 1)), build_Table = Table.FromList( monthList, Splitter.SplitByNothing(), type table [Date = Date.Type], null, ExtraValues.Error ), add_Records = Table.AddColumn( build_Table, "_Table", each [Year = Date.Year([Date]), // Returns the year number
Month = Date.MonthName([Date]), // Returns month name
MonthNUM = Date.Month([Date]), // Returns Month Number
MonthYEAR = Date.ToText([Date], "MMM-yy") // Returns Short Month and Year, e.g. Jan 2023
], type [Year = number, Month = text, MonthNUM = number, MonthYEAR = text] ), expandColumns = Table.ExpandRecordColumn( add_Records, "_Table", {"Year", "Month", "MonthNUM", "MonthYEAR"}, {"Year", "Month", "MonthNUM", "MonthYEAR"} ) in expandColumns in fn

Expected behavior Query should exactly like the formatted output as shown in the web formatter

Settings Default settings (and all other settings reduced/increased line length does not improve the output)

image
UliPlabst commented 1 year ago

Hi, thank you for reporting this issue. Hopefully I have some time next week to look into it. Just from looking at your screenshot I know that the issue is the comments. Formatting comments along with the code was not an easy task so I will have to investigate what causes the issue. I will report back as soon as I have more information.

UliPlabst commented 1 year ago

Ok so I did a quick investigation just now and the bug was not as hard to find as I thought. I just deployed the fix.

PBIQueryous commented 1 year ago

Good morning!

Thank you immensely for your quick response and turn around. Im indebted to you. I absolutely love the PQ Formatter, and have used it for years, and i shall continue to use it for many years to come!

On Mon, 24 Apr 2023, 08:10 UliPlabst, @.***> wrote:

Ok so I did a quick investigation just now and the bug was not as hard to find as I thought. I just deployed the fix.

— Reply to this email directly, view it on GitHub https://github.com/mogulargmbh/m-formatter/issues/17#issuecomment-1519507732, or unsubscribe https://github.com/notifications/unsubscribe-auth/AW4GND3U4LEY4TUBLJZTJY3XCYROVANCNFSM6AAAAAAXHZCHKQ . You are receiving this because you authored the thread.Message ID: @.***>