Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete mistyped chords deletes too many characters when a bad chord includes a Special key (listed in the "all keys" section of the locale) whose keyname is longer than 1. #226

Open
Mammal4963 opened this issue Dec 11, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Mammal4963
Copy link

notepad++_wgnWyLDHc0.mp4

Describe the bug

  • A short description of the bug.
    When mis-typing a chord that includes a special key (the numpad numbers in my case) too many characters are deleted.

  • What happens, and what do you expect to happen instead?
    Type the following as a chord (without having it saved in your dictionary) with the numpad numbers "{numpad1}+{numpad5}". This will delete 14 characters because the string "numpad1" and "numpad5" are a total of 14 characters.

If you type the type the chord "1+5" from the number row instead it only deleted 2 characters.

The expected behavior is that special keys defined in the locale under all keys should only count as plus 1 to the overal length of the chord, and the delete mistyped chords feature should only backspace 1 time per eachkey mis-pressed.

Useful Details

  • Which settings do you have selected in the ZipChord settings?
    Delete mistyped chords, Restrict chords while typing,
    Also I have the following saved in the "all keys" section of the locale:
    {Numpad0:0}{Numpad1:1}{Numpad2:2}{Numpad3:3}{Numpad4:4}{Numpad5:5}{Numpad6:6}{Numpad7:7}{Numpad8:8}{Numpad9:9}

  • If the output is wrong, what is the sequence of keys pressed, the dictionary entry, and what text appears on the screen?
    Please see the attached video, there are too many backspaces when mistyping a chord involving a special key defined in the locale.

@Mammal4963 Mammal4963 added the bug Something isn't working label Dec 11, 2024
@Mammal4963 Mammal4963 changed the title Delete mistyped chords deletes to many characters when a bad chord includes a Special key (listed in the "all keys" section of the locale) whose keyname is longer than 1. Delete mistyped chords deletes too many characters when a bad chord includes a Special key (listed in the "all keys" section of the locale) whose keyname is longer than 1. Dec 11, 2024
@Mammal4963
Copy link
Author

Mammal4963 commented Dec 11, 2024

for now I just modified the RemoveRawChord function in the io.ahk file to look like the following.

    _RemoveRawChord() {
        if !(settings.chording & CHORD_DELETE_UNRECOGNIZED) {
            return
        }
        if (settings.chording & CHORD_RESTRICT && this._IsRestricted(this.length-1) ) {
            return
        }
        raw_output := this.GetChunk(this.length).output

; this is the line I added... It is a crude solution, but solves the issue I'm having. I'm sure you will come up with something better. 
;######
        raw_output := StrReplace(raw_output, "numpad" , "") 
;######

        OutputKeys("{Backspace " . StrLen(raw_output) . "}")
        this._sequence.RemoveAt(this.length)
        return true
    }

@Mammal4963
Copy link
Author

Actually now that I think about it, this is better for my usecase, I would prefer the numpad to not count at all as mistyped chords. I don't chord on the numpad so would prefer it to just function normally. As a result I changed the line in the above function to the below instead. Just sharing in case any one else comes across this.

        raw_output := RegExReplace(raw_output, "i)numpad.", "")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant