Skip to content

fix(config): support Unicode keymap aliases - #1004

Merged
HaoboGu merged 3 commits into
rmk-rs:mainfrom
tianrking:codex/keymap-unicode-aliases
Sep 2, 2026
Merged

fix(config): support Unicode keymap aliases#1004
HaoboGu merged 3 commits into
rmk-rs:mainfrom
tianrking:codex/keymap-unicode-aliases

Conversation

@tianrking

@tianrking tianrking commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Related to #569.

Summary

  • Parse alias identifiers on UTF-8 character boundaries instead of byte offsets, preventing non-ASCII names from producing invalid string slices.
  • Use the same Unicode whitespace definition for alias scanning and keymap parsing, so separators such as NBSP and ideographic space remain valid after expansion.
  • Preserve the existing alias delimiters, case sensitivity, recursion limit, and [aliases] configuration format.
  • Add regression coverage for direct Unicode aliases, recursive expansion into an action, undefined Unicode aliases, and Unicode whitespace separators.
  • Document the supported behavior and add a changelog entry.

Validation

  • cargo test --manifest-path rmk-config/Cargo.toml (92 unit tests and 6 integration tests passed; doc tests passed)
  • cargo clippy --manifest-path rmk-config/Cargo.toml --all-targets --all-features -- -D warnings
  • cargo +nightly fmt --manifest-path rmk-config/Cargo.toml --check
  • git diff upstream/main...HEAD --check

Scope

This PR fixes Unicode handling in the existing keyboard.toml [aliases] path. It does not add the Rust-code alias API requested in #569, so that issue should remain open.

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown

Size Report

Example main PR Diff .text .data .bss
use_config/nrf52832_ble 363.2 KiB 363.2 KiB +0.00% ⬇️ -4 0 0
use_config/nrf52840_ble 422.4 KiB 422.4 KiB +0.00% ⬇️ -4 0 0
use_config/nrf52840_ble_split (central) 495.3 KiB 495.3 KiB +0.00% 0 0 0
use_config/nrf52840_ble_split (peripheral) 316.3 KiB 316.3 KiB +0.00% ⬇️ -4 0 0
use_config/pi_pico_w_ble 669.9 KiB 669.9 KiB +0.00% ⬇️ -4 0 0
use_config/rp2040 146.6 KiB 146.6 KiB +0.00% 0 0 0
use_config/rp2040_split (central) 161.5 KiB 161.5 KiB +0.00% 0 0 0
use_config/rp2040_split (peripheral) 27.8 KiB 27.8 KiB +0.00% 0 0 0
use_config/stm32f1 63.0 KiB 63.0 KiB +0.00% 0 0 0
use_config/stm32h7 101.0 KiB 101.0 KiB +0.00% 0 0 0
use_rust/nrf52832_ble 351.1 KiB 351.1 KiB +0.00% 0 0 0
use_rust/nrf52840_ble 416.7 KiB 416.7 KiB +0.00% ⬇️ -4 0 0
use_rust/nrf52840_ble_split (central) 494.0 KiB 494.0 KiB +0.00% 0 0 0
use_rust/nrf52840_ble_split (peripheral) 308.1 KiB 308.1 KiB +0.00% ⬇️ -4 0 0
use_rust/pi_pico_w_ble 669.2 KiB 669.2 KiB +0.00% ⬆️ +12 0 0
use_rust/rp2040 146.1 KiB 146.1 KiB +0.00% ⬆️ +4 0 0
use_rust/rp2040_split (central) 160.2 KiB 160.2 KiB +0.00% ⬆️ +4 0 0
use_rust/rp2040_split (peripheral) 28.2 KiB 28.2 KiB +0.00% 0 0 0
use_rust/stm32f1 62.3 KiB 62.3 KiB +0.00% 0 0 0
use_rust/stm32h7 119.5 KiB 119.5 KiB +0.00% ⬆️ +4 0 0
use_config/nrf52832_ble — 363.2 KiB → 363.2 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 330276	   8592	  33056	 371924	  5acd4	rmk-nrf52832

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 330280	   8592	  33056	 371928	  5acd8	rmk-nrf52832

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +288  [ = ]       0    .debug_info
  +0.1%    +266  [ = ]       0    .debug_line
  +0.0%     +29  [ = ]       0    .debug_str
   +11%      +6  [ = ]       0    [Unmapped]
  -0.0%      -4  -0.0%      -4    .text
  -0.0%     -33  [ = ]       0    .strtab
  +0.0%    +552  -0.0%      -4    TOTAL
use_config/nrf52840_ble — 422.4 KiB → 422.4 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 379712	   8628	  44176	 432516	  69984	rmk-nrf52840

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 379716	   8628	  44176	 432520	  69988	rmk-nrf52840

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +821  [ = ]       0    .debug_str
  +0.1%    +236  [ = ]       0    .debug_line
  +0.0%    +216  [ = ]       0    .debug_info
  +0.0%     +59  [ = ]       0    .strtab
  -0.0%      -4  -0.0%      -4    .text
  -0.0%     -12  [ = ]       0    .debug_loc
  +0.0% +1.29Ki  -0.0%      -4    TOTAL
use_config/nrf52840_ble_split (central) — 495.3 KiB → 495.3 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 448088	   8668	  50408	 507164	  7bd1c	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 448088	   8668	  50408	 507164	  7bd1c	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.4%     +39  [ = ]       0    .debug_abbrev
  -4.6%      -3  [ = ]       0    [Unmapped]
  -0.0%     -18  [ = ]       0    .strtab
  -0.0%     -22  [ = ]       0    .debug_line
  -0.0%     -34  [ = ]       0    .debug_info
  -0.0%    -486  [ = ]       0    .debug_str
  -0.0%    -524  [ = ]       0    TOTAL
use_config/nrf52840_ble_split (peripheral) — 316.3 KiB → 316.3 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 289852	   8508	  25512	 323872	  4f120	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 289856	   8508	  25512	 323876	  4f124	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +133  [ = ]       0    .debug_info
  +9.3%      +5  [ = ]       0    [Unmapped]
  +0.0%      +1  [ = ]       0    .debug_line
  -0.0%      -4  -0.0%      -4    .text
  -0.0%     -10  [ = ]       0    .strtab
  -0.0%    -109  [ = ]       0    .debug_str
  +0.0%     +16  -0.0%      -4    TOTAL
use_config/pi_pico_w_ble — 669.9 KiB → 669.9 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 631808	      0	  54200	 686008	  a77b8	rmk-pi-pico-w

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 631812	      0	  54200	 686012	  a77bc	rmk-pi-pico-w

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +215  [ = ]       0    .debug_info
  +0.0%     +31  [ = ]       0    .debug_line
  +0.0%     +29  [ = ]       0    .debug_str
  +0.0%     +19  [ = ]       0    .strtab
  -0.0%      -4  -0.0%      -4    .text
  -0.0%     -10  [ = ]       0    .debug_loc
 -40.5%     -32  [ = ]       0    [Unmapped]
  +0.0%    +248  -0.0%      -4    TOTAL
use_config/rp2040 — 146.6 KiB → 146.6 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 135896	      0	  14196	 150092	  24a4c	rmk-rp2040

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 135896	      0	  14196	 150092	  24a4c	rmk-rp2040

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +1.99Ki  [ = ]       0    .debug_str
  +0.2%    +210  [ = ]       0    .strtab
  +0.0%     +10  [ = ]       0    .debug_loc
  -1.7%      -1  [ = ]       0    [Unmapped]
  +0.1% +2.20Ki  [ = ]       0    TOTAL
use_config/rp2040_split (central) — 161.5 KiB → 161.5 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 150052	      0	  15276	 165328	  285d0	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 150052	      0	  15276	 165328	  285d0	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +10  [ = ]       0    .debug_loc
  -2.3%      -1  [ = ]       0    [Unmapped]
  -0.0%      -9  [ = ]       0    .strtab
  -0.0%     -12  [ = ]       0    .debug_info
  -0.1%    -111  [ = ]       0    .debug_line
  -0.0%    -141  [ = ]       0    .debug_str
  -0.0%    -264  [ = ]       0    TOTAL
use_config/rp2040_split (peripheral) — 27.8 KiB → 27.8 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  25520	     60	   2908	  28488	   6f48	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  25520	     60	   2908	  28488	   6f48	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL
use_config/stm32f1 — 63.0 KiB → 63.0 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  57840	     28	   6660	  64528	   fc10	rmk-stm32f1

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  57840	     28	   6660	  64528	   fc10	rmk-stm32f1

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +13  [ = ]       0    .debug_info
  -1.5%      -1  [ = ]       0    [Unmapped]
  -0.0%      -9  [ = ]       0    .strtab
  -0.0%     -63  [ = ]       0    .debug_str
  -0.0%     -60  [ = ]       0    TOTAL
use_config/stm32h7 — 101.0 KiB → 101.0 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  94760	    264	   8412	 103436	  1940c	rmk-stm32h7

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  94760	    264	   8412	 103436	  1940c	rmk-stm32h7

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL
use_rust/nrf52832_ble — 351.1 KiB → 351.1 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 317896	   8592	  33000	 359488	  57c40	rmk-nrf52832

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 317896	   8592	  33000	 359488	  57c40	rmk-nrf52832

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +3.5%      +2  [ = ]       0    [Unmapped]
  -0.0%     -10  [ = ]       0    .debug_loc
  -0.0%      -8  [ = ]       0    TOTAL
use_rust/nrf52840_ble — 416.7 KiB → 416.7 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 376700	   8628	  41408	 426736	  682f0	rmk-nrf52840

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 376704	   8628	  41408	 426740	  682f4	rmk-nrf52840

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%    +271  [ = ]       0    .debug_line
  -1.5%      -1  [ = ]       0    [Unmapped]
  -0.0%      -4  -0.0%      -4    .text
  -0.0%     -10  [ = ]       0    .debug_loc
  +0.0%    +256  -0.0%      -4    TOTAL
use_rust/nrf52840_ble_split (central) — 494.0 KiB → 494.0 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 445328	   8668	  51824	 505820	  7b7dc	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 445328	   8668	  51824	 505820	  7b7dc	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL
use_rust/nrf52840_ble_split (peripheral) — 308.1 KiB → 308.1 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 281964	   8508	  25056	 315528	  4d088	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 281968	   8508	  25056	 315532	  4d08c	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +133  [ = ]       0    .debug_info
  +0.0%      +1  [ = ]       0    .debug_line
  -3.9%      -3  [ = ]       0    [Unmapped]
  -0.0%      -4  -0.0%      -4    .text
  -0.0%     -10  [ = ]       0    .strtab
  -0.0%    -109  [ = ]       0    .debug_str
  +0.0%      +8  -0.0%      -4    TOTAL
use_rust/pi_pico_w_ble — 669.2 KiB → 669.2 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 631416	      0	  53880	 685296	  a74f0	rmk-pi-pico-w

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 631404	      0	  53880	 685284	  a74e4	rmk-pi-pico-w

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +2.48Ki  [ = ]       0    .debug_str
  +0.1%    +374  [ = ]       0    .strtab
  +0.0%    +215  [ = ]       0    .debug_info
  +0.0%     +33  [ = ]       0    .debug_line
  +0.0%     +12  +0.0%     +12    .text
 -17.1%     -12  [ = ]       0    [Unmapped]
  +0.0% +3.09Ki  +0.0%     +12    TOTAL
use_rust/rp2040 — 146.1 KiB → 146.1 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 135552	      0	  14028	 149580	  2484c	rmk-rp2040

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 135548	      0	  14028	 149576	  24848	rmk-rp2040

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +72  [ = ]       0    .debug_str
  +0.0%     +10  [ = ]       0    .debug_loc
  +0.0%      +8  [ = ]       0    .strtab
  +0.0%      +4  +0.0%      +4    .text
  -5.4%      -3  [ = ]       0    [Unmapped]
  -0.0%     -13  [ = ]       0    .debug_line
  -0.0%     -22  [ = ]       0    .debug_info
  +0.0%     +56  +0.0%      +4    TOTAL
use_rust/rp2040_split (central) — 160.2 KiB → 160.2 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 149000	      0	  15020	 164020	  280b4	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 148996	      0	  15020	 164016	  280b0	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +2.45Ki  [ = ]       0    .debug_str
  +0.2%    +248  [ = ]       0    .strtab
  +0.0%     +10  [ = ]       0    .debug_loc
  +0.0%      +4  +0.0%      +4    .text
 -13.6%      -6  [ = ]       0    [Unmapped]
  -0.0%     -37  [ = ]       0    .debug_info
  -0.1%    -124  [ = ]       0    .debug_line
  +0.1% +2.54Ki  +0.0%      +4    TOTAL
use_rust/rp2040_split (peripheral) — 28.2 KiB → 28.2 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  25632	     60	   3172	  28864	   70c0	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  25632	     60	   3172	  28864	   70c0	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL
use_rust/stm32f1 — 62.3 KiB → 62.3 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  57220	     28	   6580	  63828	   f954	rmk-stm32f1

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  57220	     28	   6580	  63828	   f954	rmk-stm32f1

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +6.7%      +3  [ = ]       0    [Unmapped]
  +0.0%      +1  [ = ]       0    .debug_str
  +0.0%      +4  [ = ]       0    TOTAL
use_rust/stm32h7 — 119.5 KiB → 119.5 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 107720	    320	  14316	 122356	  1ddf4	rmk-stm32h7

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 107716	    320	  14316	 122352	  1ddf0	rmk-stm32h7

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%      +8  [ = ]       0    .strtab
  +0.0%      +4  +0.0%      +4    .text
  -0.0%     -10  [ = ]       0    .debug_loc
  -0.0%     -38  [ = ]       0    .debug_str
  -0.0%     -59  [ = ]       0    .debug_info
  -0.1%    -137  [ = ]       0    .debug_line
  -0.0%    -232  +0.0%      +4    TOTAL

@tianrking
tianrking marked this pull request as ready for review July 26, 2026 17:31

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46d66a2247

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread rmk-config/src/layout.rs Outdated
@HaoboGu

HaoboGu commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

This cannot close #569

@HaoboGu

HaoboGu commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

@tianrking Hey could you please update the PR and fix the issue/comment? Thanks!

@tianrking
tianrking force-pushed the codex/keymap-unicode-aliases branch from 46d66a2 to 94cc07d Compare August 12, 2026 15:12
@HaoboGu
HaoboGu merged commit acd1254 into rmk-rs:main Sep 2, 2026
7 checks passed
Schievel1 pushed a commit to Schievel1/rmk that referenced this pull request Sep 2, 2026
* fix(config): support Unicode keymap aliases

* Update CHANGELOG.md

---------

Co-authored-by: HaoboGu <haobogu@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants