Skip to content

feat(VSCode): pass highlighted content as model context#423

Open
Githubguy132010 wants to merge 4 commits intoKilo-Org:devfrom
Githubguy132010:feat/vscode-selection-context-401
Open

feat(VSCode): pass highlighted content as model context#423
Githubguy132010 wants to merge 4 commits intoKilo-Org:devfrom
Githubguy132010:feat/vscode-selection-context-401

Conversation

@Githubguy132010
Copy link

@Githubguy132010 Githubguy132010 commented Feb 18, 2026

Fixes #401

Context

This PR adds VS Code support for passing the currently highlighted editor content as focused model context when sending a chat/edit message. This addresses #401 and helps the model focus on the exact block a user is asking about.

Implementation

  • Added editorContextUrl() in packages/kilo-vscode/src/editor-context.ts.
  • The helper converts the active editor selection into file://...?...start=<line>&end=<line> query params.
  • Updated KiloProvider to use that helper when injecting active editor file context.
  • Kept previous behavior for empty selection (full file URL without range params).
  • Added targeted unit tests for URL generation edge cases:
    • empty selection
    • normal multi-line selection
    • reversed selection direction
    • line-boundary selection ending at column 0

Screenshots

before after
N/A (context payload change) N/A (context payload change)

How to Test

  • Open VS Code with the Kilo extension and any code file.
  • Highlight a block of code and send a prompt (for example: what does this code block do?).
  • Confirm model responses are focused on the selected block.
  • Repeat with no selection and confirm normal full-file context behavior.
  • Automated checks run in this branch:
    • bun run --cwd packages/kilo-vscode check-types
    • bun test tests/unit/editor-context.test.ts (from packages/kilo-vscode/)

Get in Touch

thomas07374

@github-actions
Copy link
Contributor

Hey! Your PR title [FEATURE] VSCode: pass highlighted content as model context (#401) doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, kilo).

See CONTRIBUTING.md for details.

@Githubguy132010 Githubguy132010 changed the title [FEATURE] VSCode: pass highlighted content as model context (#401) feat:(VSCode): pass highlighted content as model context (#401) Feb 18, 2026
@Githubguy132010 Githubguy132010 changed the title feat:(VSCode): pass highlighted content as model context (#401) feat(VSCode): pass highlighted content as model context Feb 18, 2026
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.

[FEATURE]: Add support for passing highlighted content to model when editing (VSCode)

1 participant