mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
feat(vscode-ide-companion): send initial active editor state to WebView on initialization
- Send activeEditorChanged message with initial editor state when WebView is created - Include fileName, filePath, and selection info if available - Applied in both side panel and editor panel initialization This ensures the WebView displays the current file context immediately on load. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -231,6 +231,27 @@ export class WebViewProvider {
|
||||
});
|
||||
this.disposables.push(selectionChangeDisposable);
|
||||
|
||||
// Send initial active editor state to WebView
|
||||
const initialEditor = vscode.window.activeTextEditor;
|
||||
if (initialEditor) {
|
||||
const filePath = initialEditor.document.uri.fsPath || null;
|
||||
const fileName = filePath ? getFileName(filePath) : null;
|
||||
|
||||
let selectionInfo = null;
|
||||
if (!initialEditor.selection.isEmpty) {
|
||||
const selection = initialEditor.selection;
|
||||
selectionInfo = {
|
||||
startLine: selection.start.line + 1,
|
||||
endLine: selection.end.line + 1,
|
||||
};
|
||||
}
|
||||
|
||||
this.sendMessageToWebView({
|
||||
type: 'activeEditorChanged',
|
||||
data: { fileName, filePath, selection: selectionInfo },
|
||||
});
|
||||
}
|
||||
|
||||
// Check if we have valid auth cache and auto-reconnect
|
||||
if (!this.agentInitialized) {
|
||||
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
|
||||
@@ -520,6 +541,27 @@ export class WebViewProvider {
|
||||
);
|
||||
this.disposables.push(editorChangeDisposable);
|
||||
|
||||
// Send initial active editor state to WebView
|
||||
const initialEditor = vscode.window.activeTextEditor;
|
||||
if (initialEditor) {
|
||||
const filePath = initialEditor.document.uri.fsPath || null;
|
||||
const fileName = filePath ? getFileName(filePath) : null;
|
||||
|
||||
let selectionInfo = null;
|
||||
if (!initialEditor.selection.isEmpty) {
|
||||
const selection = initialEditor.selection;
|
||||
selectionInfo = {
|
||||
startLine: selection.start.line + 1,
|
||||
endLine: selection.end.line + 1,
|
||||
};
|
||||
}
|
||||
|
||||
this.sendMessageToWebView({
|
||||
type: 'activeEditorChanged',
|
||||
data: { fileName, filePath, selection: selectionInfo },
|
||||
});
|
||||
}
|
||||
|
||||
// Capture the tab reference on restore
|
||||
this.panelManager.captureTab();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user