Skip to content

fix: prioritize @ file search over slash command completion#2519

Open
Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Br1an67:fix/at-completion-after-slash-command
Open

fix: prioritize @ file search over slash command completion#2519
Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Br1an67:fix/at-completion-after-slash-command

Conversation

@Br1an67
Copy link
Contributor

@Br1an67 Br1an67 commented Mar 20, 2026

TLDR

Fix @ file search not working after selecting a custom slash command on the same line.

Fixes #2518

Dive Deeper

Root Cause

In useCommandCompletion, the completion mode detection checks for slash commands before checking for @ file references:

if (cursorRow === 0 && isSlashCommand(currentLine.trim())) {
  return { completionMode: CompletionMode.SLASH, ... };
}
// @ detection never reached when line starts with /

Since isSlashCommand() returns true for any line starting with / (excluding // and /*), typing @ after a completed slash command like /qc:create-issue @readme still matches the slash command check first, and the @ file search code is never executed.

Fix

Reorder the completion mode detection to check for @ file references before slash commands. When the cursor is positioned after an @ character (within the current word boundary), AT mode takes priority. If no @ is found, the slash command check runs as before.

This preserves all existing behaviors:

  • /help → SLASH mode (no @ in text) ✓
  • /model qwen3 → SLASH mode (no @ in text) ✓
  • /qc:create-issue @readme → AT mode (@ found before cursor) ✓
  • @file → AT mode (no change) ✓
  • plain text → IDLE mode (no change) ✓

Testing Matrix

  • All 15 existing + new tests pass (useCommandCompletion.test.ts)
  • Added regression test: @ after slash command triggers AT completion
  • Pre-commit hooks (prettier + eslint) pass

When typing @ after a custom slash command on the same line (e.g.,
`/qc:create-issue @readme`), the @ file search feature was not
triggered because the slash command check ran first and returned
SLASH mode for the entire line.

Reorder the completion mode detection to check for @ file references
before slash commands. This ensures file search works correctly when
@ appears after a slash command, while preserving all existing slash
command and @ completion behaviors.

Fixes QwenLM#2518
@tanzhenxin
Copy link
Collaborator

@Br1an67 Thanks for your contributions to Qwen Code! But we are really appreciate if you can take time to do manual testing before submitting PR, I mean it is kind of the bottleneck work of current "Vibe Coding" world.

A screenshot after fix would be very great. We will take it as a proof of work to guide us to allocate resources for the PR review.

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.

@ file search stops working after selecting a custom slash command

2 participants