mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
feat(vscode-ide-companion/diff): implement diff auto-open functionality in preferred editor group
This commit is contained in:
@@ -12,6 +12,10 @@ import { type JSONRPCNotification } from '@modelcontextprotocol/sdk/types.js';
|
||||
import * as path from 'node:path';
|
||||
import * as vscode from 'vscode';
|
||||
import { DIFF_SCHEME } from './extension.js';
|
||||
import {
|
||||
findLeftGroupOfChatWebview,
|
||||
ensureLeftGroupOfChatWebview,
|
||||
} from './utils/editorGroupUtils.js';
|
||||
|
||||
export class DiffContentProvider implements vscode.TextDocumentContentProvider {
|
||||
private content = new Map<string, string>();
|
||||
@@ -110,13 +114,28 @@ export class DiffManager {
|
||||
true,
|
||||
);
|
||||
|
||||
// Prefer opening the diff adjacent to the chat webview (so we don't
|
||||
// replace content inside the locked webview group). We try the group to
|
||||
// the left of the chat webview first; if none exists we fall back to
|
||||
// ViewColumn.Beside. With the chat locked in the leftmost group, this
|
||||
// fallback opens diffs to the right of the chat.
|
||||
let targetViewColumn = findLeftGroupOfChatWebview();
|
||||
if (targetViewColumn === undefined) {
|
||||
// If there is no left neighbor, create one to satisfy the requirement of
|
||||
// opening diffs to the left of the chat webview.
|
||||
targetViewColumn = await ensureLeftGroupOfChatWebview();
|
||||
}
|
||||
|
||||
await vscode.commands.executeCommand(
|
||||
'vscode.diff',
|
||||
leftDocUri,
|
||||
rightDocUri,
|
||||
diffTitle,
|
||||
{
|
||||
viewColumn: vscode.ViewColumn.Beside,
|
||||
// If a left-of-webview group was found, target it explicitly so the
|
||||
// diff opens there while keeping focus on the webview. Otherwise, use
|
||||
// the default "open to side" behavior.
|
||||
viewColumn: targetViewColumn ?? vscode.ViewColumn.Beside,
|
||||
preview: false,
|
||||
preserveFocus: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user