@@ -1761,16 +1761,23 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
17611761 }
17621762
17631763 // 'Add to Cline' context menu in editor and code action
1764- async addSelectedCodeToChat ( code : string , filePath : string , languageId : string ) {
1764+ async addSelectedCodeToChat ( code : string , filePath : string , languageId : string , diagnostics ?: vscode . Diagnostic [ ] ) {
17651765 // Ensure the sidebar view is visible
17661766 await vscode . commands . executeCommand ( "claude-dev.SidebarProvider.focus" )
17671767 await delay ( 100 )
17681768
17691769 // Post message to webview with the selected code
17701770 const fileMention = this . getFileMentionFromPath ( filePath )
1771+
1772+ let input = `${ fileMention } \n\`\`\`\n${ code } \n\`\`\``
1773+ if ( diagnostics ) {
1774+ const problemsString = this . convertDiagnosticsToProblemsString ( diagnostics )
1775+ input += `\nProblems:\n${ problemsString } `
1776+ }
1777+
17711778 await this . postMessageToWebview ( {
17721779 type : "addToInput" ,
1773- text : ` ${ fileMention } \n\`\`\`\n ${ code } \n\`\`\`` ,
1780+ text : input ,
17741781 } )
17751782
17761783 console . log ( "addSelectedCodeToChat" , code , filePath , languageId )
@@ -1804,7 +1811,15 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
18041811 await delay ( 100 )
18051812
18061813 const fileMention = this . getFileMentionFromPath ( filePath )
1814+ const problemsString = this . convertDiagnosticsToProblemsString ( diagnostics )
1815+ await this . initClineWithTask (
1816+ `Fix the following code in ${ fileMention } \n\`\`\`\n${ code } \n\`\`\`\n\nProblems:\n${ problemsString } ` ,
1817+ )
18071818
1819+ console . log ( "fixWithCline" , code , filePath , languageId , diagnostics , problemsString )
1820+ }
1821+
1822+ convertDiagnosticsToProblemsString ( diagnostics : vscode . Diagnostic [ ] ) {
18081823 let problemsString = ""
18091824 for ( const diagnostic of diagnostics ) {
18101825 let label : string
@@ -1828,12 +1843,8 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
18281843 const source = diagnostic . source ? `${ diagnostic . source } ` : ""
18291844 problemsString += `\n- [${ source } ${ label } ] Line ${ line } : ${ diagnostic . message } `
18301845 }
1831-
1832- await this . initClineWithTask (
1833- `Fix the following code in ${ fileMention } \n\`\`\`\n${ code } \n\`\`\`\n\nProblems:\n${ problemsString . trim ( ) } ` ,
1834- )
1835-
1836- console . log ( "fixWithCline" , code , filePath , languageId , diagnostics , problemsString )
1846+ problemsString = problemsString . trim ( )
1847+ return problemsString
18371848 }
18381849
18391850 // Task history
0 commit comments