Skip to content

TagGenerator should support customizable single-letter tag order via YAML config #307

@dimiour

Description

@dimiour

Feature Request

Problem
The current TagGenerator generates two-letter tags sequentially ("aa", "ab", ..., "zz") using the standard alphabet order. This feature request proposes enabling a customizable order for tag generation via a YAML configuration file, but only for single-letter tags (e.g., 'a', 's', 'd', 'f', etc.). This would allow users to prioritize keys closer to the homerow or any preferred layout, improving accessibility and ergonomics.

Proposed Solution

  • Add support for a YAML config file (e.g., tag_keys.yaml) where users can specify the order of single-letter keys to be used for tag generation.
  • The generator should use only the specified letters in the order listed in the YAML file, rather than generating all combinations.
  • Example YAML config:
# tag_keys.yaml
keys:
  - a
  - s
  - d
  - f
  - j
  - k
  - l
  - ;

Relevant Code Reference
src/models/application/modes/jump/tag_generator.rs:

pub struct TagGenerator {
    index: u16,
}

impl TagGenerator {
    /// Builds a new zero-indexed tag generator.
    pub fn new() -> TagGenerator {
        TagGenerator { index: 0 }
    }

    /// Restarts the tag generator sequence.
    pub fn reset(&mut self) {
        self.index = 0;
    }
}

impl Iterator for TagGenerator {
    type Item = String;

    // Returns the next two-letter tag, or none
    // if we've passed the limit ("zz").
    fn next(&mut self) -> Option<String> {
        if self.index > TAG_INDEX_LIMIT {
            return None;
        }

        // Calculate the tag characters based on the index value.
        let first_letter = ((self.index / 26) + 97) as u8;
        let second_letter = ((self.index % 26) + 97) as u8;

        // Increment the index.
        self.index += 1;

        // Stitch the two calculated letters together.
        match String::from_utf8(vec![first_letter, second_letter]) {
            Ok(tag) => Some(tag),
            Err(_) => panic!("Couldn't generate a valid UTF-8 jump mode tag."),
        }
    }
}

Implementation Notes

  • The generator logic would need to be refactored to optionally read the YAML config and use only the listed letters, generating tags one-by-one from the list, instead of combinations.
  • If the YAML file is absent, fallback to the default behavior.
  • Consider error handling for invalid or missing config values.

Copilot is powered by AI, so mistakes are possible. Leave a comment via the 👍 👎 to share your feedback and help improve the experience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions