Skip to content

Conversation

@aseemxs
Copy link
Contributor

@aseemxs aseemxs commented Dec 2, 2025

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

Fixes code selection not being detected when users select code in the editor and then type directly in the Amazon Q chat panel.

Root cause: The LSP server's ChatParams interface expects cursorState to be an array (CursorState[]), but JetBrains was sending it as a single object. The server code accesses cursorState?.[0] which returns undefined when given an object instead of an array, causing it to fall back to the default cursor state
(no selection).

Fix: Wrap cursorState in a list before sending to the LSP server.

Screen.Recording.2025-12-02.at.1.31.53.PM.mov

This issue affected users who:

  1. Select code in the editor
  2. Click on the chat panel and type a message directly (without using right-click context menu)

The chat would respond with "There's no highlighted code" even though code was selected.

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@aseemxs aseemxs changed the title Fix/amazonq selection detection fix(amazonq) selection detection Dec 2, 2025
The LSP server expects cursorState to be CursorState[] (array), but JetBrains
was sending it as a single object. This caused the server to fall back to
default cursor state when accessing cursorState?.[0] on a non-array value.

Fixes selection detection when user types directly in chat panel.
@aseemxs aseemxs force-pushed the fix/amazonq-selection-detection branch from 7737611 to 3ffe4e9 Compare December 3, 2025 00:13
@aseemxs aseemxs changed the title fix(amazonq) selection detection fix(amazonq): selection detection Dec 3, 2025
@aseemxs aseemxs marked this pull request as ready for review December 5, 2025 19:14
@laileni-aws laileni-aws closed this Dec 5, 2025
@laileni-aws laileni-aws reopened this Dec 5, 2025
Copy link
Contributor

@rli rli left a comment

Choose a reason for hiding this comment

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

please fix the PR title

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.

3 participants