Commit 3954302
authored
fix(amazonq): send proper cursor position to lsp (#7113)
## Problem
If you currently ask Q any questions about cursor position or
highlighted text, it lacks the context necessary to answer. This is
because in the payload sent to the LSP we send the cursor position as
the wrong type:
https://github.com/aws/aws-toolkit-vscode/blob/2e8d4c7eb0f0bcbc416d8f6e06ff7e00d57dc6b2/packages/amazonq/src/lsp/chat/messages.ts#L159
whereas
[Flare](https://github.com/aws/language-server-runtimes/blob/d9960b5dd6df52c52309f0a7edae64a824da9003/types/chat.ts#L82)
is expecting: `cursorState`.
## Solution
- Convert the vscode selection to a Flare cursorState.
- Add stronger typing by casting the params to `ChatParams` type before
modifying to avoid these types of bugs.
## Future Work
- This fixes flare being unable to identify cursor position, and mostly
fixes highlighted text. However, I was still able to run into situations
where the cursor position is correct, but the content is incorrect.
~~This could be fixed by sending the highlighted content to Flare, but~~
still trying to root cause the issue.
<img width="1064" alt="image"
src="https://github.com/user-attachments/assets/35e6fbc9-5c66-4f9f-8c6e-bf9ec4ab4ef2"
/>
---
- Treat all work as PUBLIC. Private `feature/x` branches will not be
squash-merged at release time.
- Your code changes must meet the guidelines in
[CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.1 parent 2e8d4c7 commit 3954302
1 file changed
+21
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
75 | 90 | | |
76 | 91 | | |
77 | 92 | | |
| |||
147 | 162 | | |
148 | 163 | | |
149 | 164 | | |
| 165 | + | |
150 | 166 | | |
151 | 167 | | |
152 | | - | |
| 168 | + | |
153 | 169 | | |
154 | 170 | | |
155 | 171 | | |
156 | 172 | | |
157 | 173 | | |
158 | 174 | | |
159 | | - | |
160 | | - | |
| 175 | + | |
| 176 | + | |
161 | 177 | | |
162 | 178 | | |
163 | | - | |
| 179 | + | |
164 | 180 | | |
165 | 181 | | |
166 | 182 | | |
| |||
169 | 185 | | |
170 | 186 | | |
171 | 187 | | |
172 | | - | |
| 188 | + | |
173 | 189 | | |
174 | 190 | | |
175 | 191 | | |
| |||
0 commit comments