Format indentation should remove blank space on end of lines

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Format indentation should remove blank space on end of lines

Post by Sicro »

It would be nice to see that the menu command "Edit => Format indentation" would also remove spaces at the end of each line of code.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Format indentation should remove blank space on end of l

Post by collectordave »

+1
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
Mohawk70
Enthusiast
Enthusiast
Posts: 400
Joined: Thu May 11, 2006 1:04 am
Location: Florida, USA

Re: Format indentation should remove blank space on end of l

Post by Mohawk70 »

I've found that quirk to be quite annoying ... I agree. Although in my opinion it ranks
low on the list , below actual bug fixes.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Format indentation should remove blank space on end of l

Post by #NULL »

if you consider macros then spaces at the end of a line might not always be outside of a string (note the spaces in a()):

Code: Select all

Macro a()
  "x         
EndMacro
Macro b()
  x"
EndMacro
s.s = a() b()
Debug s
spaces at the beginning of the macro body are already ignored as indentation though (don't know right now if only for the first line).
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Format indentation should remove blank space on end of l

Post by Dude »

I agree with the above: this would break macros that rely on spaces. So, I vote no.
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Format indentation should remove blank space on end of l

Post by Keya »

maybe just don't apply the fix to lines within macros?
i like the suggestion - i dont know why but the PB IDE seems to add a lot of extra spaces after some lines for no reason (somewhat intermittently), which frustrates me a lot when im trying to quickly navigate to the end of a line (often) and have to waste time clicking over useless spaces i never added in the first place
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Format indentation should remove blank space on end of l

Post by IdeasVacuum »

Instead of "Edit => Format indentation" additionally removing spaces at the end of lines, let's have a separate command for that task.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: Format indentation should remove blank space on end of l

Post by Sicro »

@#Null:
Is such code often in use?
There are certainly many programmers here who also use other text editors besides the PB-IDE. Some of them have possibly defaulted settings that remove trailing spaces.
IdeasVacuum wrote:Instead of "Edit => Format indentation" additionally removing spaces at the end of lines, let's have a separate command for that task.
That's okay for me, too.
Or replace the menu item with "Reformat code". You can then specify in the preferences what the menu item should do (adjust indentation, remove trailing spaces, etc.).
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Format indentation should remove blank space on end of l

Post by #NULL »

Sicro wrote:@#Null:
Is such code often in use?
I don't think so, I've never seen or used it. But that the behavior of the program might change by such a modification is something that should be considered. It can also be avoided by using

Code: Select all

Macro a()
  "x         "+"
EndMacro
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: Format indentation should remove blank space on end of l

Post by Sicro »

#NULL wrote:But that the behavior of the program might change by such a modification is something that should be considered.
Yes, that's why I think the suggestion of @Keya to leave the trailing spaces/tabs within macro blocks untouched is a good compromise.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Post Reply