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

View File

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