feat: Implement shortcut for DevChat input focus

- Added keybindings for DevChat input focus shortcut
- Implemented focusHandler to focus on DevChat input upon shortcut
This commit is contained in:
bobo.yang 2024-02-07 17:37:02 +08:00
parent 2ea5226ad2
commit d87b7c5801
3 changed files with 20 additions and 1 deletions

View File

@ -2,7 +2,7 @@
"name": "devchat",
"displayName": "DevChat",
"description": "Write prompts, not code",
"version": "0.1.55",
"version": "0.1.65",
"icon": "assets/devchat.png",
"publisher": "merico",
"engines": {
@ -670,6 +670,13 @@
"category": "DevChat"
}
],
"keybindings": [
{
"command": "devchat.openChatPanel",
"key": "ctrl+shift+/",
"mac": "cmd+shift+/"
}
],
"menus": {
"editor/title": [
{

View File

@ -17,6 +17,7 @@ import DevChat from "../toolwrapper/devchat";
import { createEnvByConda, createEnvByMamba } from '../util/python_installer/app_install';
import { installRequirements } from '../util/python_installer/package_install';
import { chatWithDevChat } from '../handler/chatHandler';
import { focusDevChatInput } from '../handler/focusHandler';
const readdir = util.promisify(fs.readdir);
const stat = util.promisify(fs.stat);
@ -42,6 +43,7 @@ async function copyDirectory(src: string, dest: string): Promise<void> {
function registerOpenChatPanelCommand(context: vscode.ExtensionContext) {
let disposable = vscode.commands.registerCommand('devchat.openChatPanel', async () => {
await vscode.commands.executeCommand('devchat-view.focus');
await focusDevChatInput(ExtensionContextHolder.provider?.view()!);
});
context.subscriptions.push(disposable);
}

View File

@ -0,0 +1,10 @@
import * as vscode from 'vscode';
import { MessageHandler } from './messageHandler';
export async function focusDevChatInput(panel: vscode.WebviewPanel|vscode.WebviewView): Promise<void> {
const inputFocusMessage = {"command": "focusDevChatInput"};
if (panel) {
MessageHandler.sendMessage(panel, inputFocusMessage);
}
}