Skip to content

Commit a479a42

Browse files
fix(amazonq): improve line numbering in Explain and Fix commands
1 parent 11bcfc9 commit a479a42

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/amazonq/src/lsp/chat/commands.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
4141
})
4242
}
4343

44-
const visibleMessageInChat = `_Explain **${issue.title}** issue in **${path.basename(filePath)}** at \`(${issue.startLine}, ${issue.endLine})\`_`
44+
const lineRange =
45+
issue.startLine === issue.endLine - 1
46+
? `[${issue.startLine + 1}]`
47+
: `[${issue.startLine + 1}, ${issue.endLine}]`
48+
const visibleMessageInChat = `_Explain **${issue.title}** issue in **${path.basename(filePath)}** at \`${lineRange}\`_`
4549

4650
// The message that gets sent to the backend
4751
const contextMessage = `Provide a small description of the issue. Do not attempt to fix the issue, only explain it. Code issue - ${JSON.stringify(issue)}`
@@ -73,7 +77,11 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
7377
})
7478
}
7579

76-
const visibleMessageInChat = `_Fix **${issue.title}** issue in **${path.basename(filePath)}** at \`(${issue.startLine}, ${issue.endLine})\`_`
80+
const lineRange =
81+
issue.startLine === issue.endLine - 1
82+
? `[${issue.startLine + 1}]`
83+
: `[${issue.startLine + 1}, ${issue.endLine}]`
84+
const visibleMessageInChat = `_Fix **${issue.title}** issue in **${path.basename(filePath)}** at \`${lineRange}\`_`
7785

7886
// The message that gets sent to the backend
7987
const contextMessage = `Generate a fix for the following code issue. Do not explain the issue, just generate and explain the fix. The user should have the option to accept or reject the fix before any code is changed. Code issue - ${JSON.stringify(issue)}`

0 commit comments

Comments
 (0)