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

Enhance Tab Completion to Work with Any Character #402

Open
4 tasks
tusharmath opened this issue Feb 27, 2025 · 9 comments · May be fixed by #423, #404 or #426
Open
4 tasks

Enhance Tab Completion to Work with Any Character #402

tusharmath opened this issue Feb 27, 2025 · 9 comments · May be fixed by #423, #404 or #426
Labels
💎 Bounty enhancement New feature or request

Comments

@tusharmath
Copy link
Collaborator

Enhance Tab Completion to Work with Any Character

Current Behavior

Currently, the tab completion feature only works after typing the '@' character. When a user types '@' and presses the Tab key, an autocomplete window pops up showing file suggestions.

Desired Behavior

Tab completion should work with any character sequence, not just after '@'. A user should be able to type any character(s) and press Tab to see matching completions.

For example:

  • Type f and press Tab → Should show completions for files beginning with 'f'
  • Type fo and press Tab → Should show completions for files beginning with 'fo', like 'foo'

Technical Details

The current implementation filters completions based on the '@' character in SearchTerm::process() method:

// In crates/forge_main/src/completer/search_term.rs
pub fn process(&self) -> Option<TermResult<'_>> {
    // Get all the indexes of the '@' chars
    // Get all chars between @ and the cursor
    let term = self
        .line
        .chars()
        .enumerate()
        .filter(|(_, c)| *c == '@')  // This specifically looks for the '@' character
        .map(|(i, _)| i)
        .filter(|at| *at < self.position)
        .max_by(|a, b| a.cmp(b))
        .map(|at| TermResult {
            span: Span::new(at + 1, self.position),
            term: &self.line[at + 1..self.position],
        })
        .filter(|s| !s.term.contains(" "));

    term
}

The InputCompleter uses this SearchTerm class to determine what to complete:

// In crates/forge_main/src/completer/input_completer.rs
if let Some(query) = SearchTerm::new(line, pos).process() {
    let files = self.walker.get_blocking().unwrap_or_default();
    files
        .into_iter()
        .filter(|file| !file.is_dir())
        .filter_map(|file| {
            // Filtering logic
        })
        .collect()
} else {
    vec![]
}

Implementation Suggestions

  1. Modify the SearchTerm::process() method to work with any character, not just '@'.
  2. Implement word boundary detection to determine what the user is trying to complete.
  3. Update the tab completion logic in editor.rs if necessary.

Acceptance Criteria

  • User can type any character and press Tab to see file completions
  • Completions are contextual to what has been typed
  • Existing functionality (like command completion) is preserved
  • Test cases are updated to reflect the new behavior

Additional Notes

This enhancement will improve the user experience by making completion more intuitive and consistent with standard CLI behavior.

@tusharmath tusharmath added the enhancement New feature or request label Feb 27, 2025
@tusharmath
Copy link
Collaborator Author

/bounty 25

Surprise tip for anyone who use forge to fix forge and shares it on social media ;)

Copy link

algora-pbc bot commented Feb 27, 2025

💎 $25 bounty • Tailcall Inc.

Steps to solve:

  1. Start working: Comment /attempt #402 with your implementation plan
  2. Submit work: Create a pull request including /claim #402 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

🙏 Thank you for contributing to antinomyhq/forge!
🧐 Checkout our guidelines before you get started.
💵 More about our bounty program.

Attempt Started (GMT+0) Solution
🔴 @Ayushjhawar8 Feb 27, 2025, 9:10:59 AM WIP
🟢 @Mayank77maruti Feb 27, 2025, 9:13:48 AM #404
🟢 @mehul-m-prajapati Mar 2, 2025, 4:21:44 AM #426
🟢 @onyedikachi-david #423

@Mayank77maruti
Copy link

Mayank77maruti commented Feb 27, 2025

/attempt #402

Algora profile Completed bounties Tech Active attempts Options
@Mayank77maruti 1 bounty from 1 project
CSS, Python,
JavaScript & more
Cancel attempt

Copy link

algora-pbc bot commented Feb 27, 2025

Note

The user @Ayushjhawar8 is already attempting to complete issue #402 and claim the bounty. We recommend checking in on @Ayushjhawar8's progress, and potentially collaborating, before starting a new solution.

Copy link

algora-pbc bot commented Feb 27, 2025

💡 @Mayank77maruti submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Copy link

algora-pbc bot commented Mar 1, 2025

💡 @onyedikachi-david submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Copy link

algora-pbc bot commented Mar 2, 2025

💡 @mehul-m-prajapati submitted a pull request that claims the bounty. You can visit your bounty board to reward.

@mehul-m-prajapati
Copy link

mehul-m-prajapati commented Mar 2, 2025

/attempt #402

Algora profile Completed bounties Tech Active attempts Options
@mehul-m-prajapati 3 tailcallhq bounties
TypeScript, JavaScript,
HTML & more
Cancel attempt

Copy link

algora-pbc bot commented Mar 2, 2025

Note

The user @Mayank77maruti is already attempting to complete issue #402 and claim the bounty. We recommend checking in on @Mayank77maruti's progress, and potentially collaborating, before starting a new solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment