maestrith / AHK-Studio

Created with AHK Studio
http://www.maestrith.com
363 stars 68 forks source link

Pressing Backspace incorrectly removes all spaces/tabs at the beginning of a line #234

Open GenesisFR opened 3 years ago

GenesisFR commented 3 years ago

I understand it is a QOL, however if you have tabbed lines like in this example:

    ReleaseAllKeys()
                KeyWait, Alt

Pressing Backspace while the caret is at the beginning of the second line will result in

    ReleaseAllKeys()                KeyWait, Alt

While pressing Backspace while the caret is before KeyWait will result in

    ReleaseAllKeys()KeyWait, Alt

I do this all the time and it's really annoying. I had to locally revert the changes from 8a7d1ae at line 421. I think the problem comes from sc.2128(Start) which isn't the beginning of the line but the end of the indentation at the beginning of the line. It should be replaced by something like GETLINEBEGINPOSITION (which I can't seem find or create).

The expected behavior should be the reverse, it should only remove tabs when you're at the beginning of the line (like stated in the commit description).

GenesisFR commented 3 years ago

Ok so I modified the code like this and it does fix the problem, however it creates a similar problem when pressing Delete at the beginning of the line:

    if(sc.2167(Start)=sc.2008&&Start>0&&sc.2008=sc.2009){
        return sc.2645((SPos:=sc.2136(Start-1)),sc.2128(Start)-SPos)
    }
GenesisFR commented 3 years ago

Alright, this should fix both problems:

    if(sc.2167(Start)=sc.2008&&Start>0&&sc.2008=sc.2009&&sub!=0){
        return sc.2645((SPos:=sc.2136(Start-1)),sc.2128(Start)-SPos)
    }
maestrith commented 3 years ago

I suppose I could make an option for it, but you can also press Shift+{Backspace} which bypasses the normal Backspace routine.

I'll look at what you coded to see if it still keeps the functionality of removing all of the spaces before the beginning of the line.

GenesisFR commented 3 years ago

It does keep that functionality as long as the caret is at the beginning of the line, before any space/tab.

GenesisFR commented 3 years ago

Now that I'm reading it again, did you mean it should also remove all spaces/tabs at the end of the previous line once the current line is merged with it? Because it doesn't in both of our versions.

maestrith commented 3 years ago

I never intended it to do that. I do not leave any whitespace at the end of my lines so it never really occurred to me.

GenesisFR commented 3 years ago

Ok, I'll update my pull request tonight to also fix that.

GenesisFR commented 3 years ago

Unfortunately, I haven't found anything that could help detecting whitespace at the end of a line in the Scintilla documentation. I don't leave whitespace at the end of lines so that's not a problem for me either.

Maybe if there's a way of reversing the order of all the characters of the previous line, removing the indentation at the beginning of the reversed line (if there's any), then reversing the line again? Just throwing an idea out there.

GenesisFR commented 3 years ago

@maestrith I don't know what you did in your commits for 1.005.37 (all commits between 1.005.00 and 1.005.37 are gone?) but #235 wasn't merged. The code is slightly different than what it was before though.

I updated AHK Studio to confirm and the issue still persists.