mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-01-11 03:19:15 +00:00
feat: wrap selected text in code blocks for IDE context
This commit is contained in:
@@ -1066,7 +1066,10 @@ describe('Gemini Client (client.ts)', () => {
|
||||
Active file:
|
||||
Path: /path/to/active/file.ts
|
||||
Cursor: line 5, character 10
|
||||
Selected text: hello
|
||||
Selected text:
|
||||
\`\`\`
|
||||
hello
|
||||
\`\`\`
|
||||
|
||||
Other open files:
|
||||
- /path/to/recent/file1.ts
|
||||
@@ -1174,7 +1177,10 @@ Other open files:
|
||||
Active file:
|
||||
Path: /path/to/active/file.ts
|
||||
Cursor: line 5, character 10
|
||||
Selected text: hello`;
|
||||
Selected text:
|
||||
\`\`\`
|
||||
hello
|
||||
\`\`\``;
|
||||
const expectedRequest = [{ text: expectedContext }];
|
||||
expect(mockChat.addHistory).toHaveBeenCalledWith({
|
||||
role: 'user',
|
||||
|
||||
@@ -237,7 +237,10 @@ export class GeminiClient {
|
||||
);
|
||||
}
|
||||
if (activeFile.selectedText) {
|
||||
contextLines.push(` Selected text: ${activeFile.selectedText}`);
|
||||
contextLines.push(' Selected text:');
|
||||
contextLines.push('```');
|
||||
contextLines.push(activeFile.selectedText);
|
||||
contextLines.push('```');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,9 +335,10 @@ export class GeminiClient {
|
||||
);
|
||||
}
|
||||
if (currentActiveFile.selectedText) {
|
||||
changeLines.push(
|
||||
` Selected text: ${currentActiveFile.selectedText}`,
|
||||
);
|
||||
changeLines.push(' Selected text:');
|
||||
changeLines.push('```');
|
||||
changeLines.push(currentActiveFile.selectedText);
|
||||
changeLines.push('```');
|
||||
}
|
||||
} else {
|
||||
const lastCursor = lastActiveFile.cursor;
|
||||
@@ -364,7 +368,10 @@ export class GeminiClient {
|
||||
changeLines.push('Selection changed:');
|
||||
changeLines.push(` Path: ${currentActiveFile.path}`);
|
||||
if (currentSelectedText) {
|
||||
changeLines.push(` Selected text: ${currentSelectedText}`);
|
||||
changeLines.push(' Selected text:');
|
||||
changeLines.push('```');
|
||||
changeLines.push(currentSelectedText);
|
||||
changeLines.push('```');
|
||||
} else {
|
||||
changeLines.push(' Selected text: (none)');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user