Merge pull request #25 from covespace/filter_invliad_editor
Filter invliad editor
This commit is contained in:
commit
736ede2114
@ -1,12 +1,10 @@
|
||||
import * as vscode from 'vscode';
|
||||
import ChatContextManager from '../context/contextManager';
|
||||
import {messageHandler} from './messageHandler';
|
||||
|
||||
async function addConext(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
export async function addConext(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
const contextStr = await ChatContextManager.getInstance().processText(message.selected);
|
||||
panel.webview.postMessage({ command: 'appendContext', context: contextStr });
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler.registerHandler('addContext', addConext);
|
||||
|
||||
|
@ -1,14 +1,15 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { messageHandler } from './messageHandler';
|
||||
|
||||
|
||||
export async function applyCode(text: string) {
|
||||
if (vscode.window.visibleTextEditors.length > 1) {
|
||||
const validVisibleTextEditors = vscode.window.visibleTextEditors.filter(editor => editor.viewColumn !== undefined);
|
||||
|
||||
if (validVisibleTextEditors.length > 1) {
|
||||
vscode.window.showErrorMessage(`There are more then one visible text editors. Please close all but one and try again.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const editor = vscode.window.visibleTextEditors[0];
|
||||
const editor = validVisibleTextEditors[0];
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
@ -23,10 +24,9 @@ export async function applyCode(text: string) {
|
||||
}
|
||||
|
||||
|
||||
async function codeApply(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
export async function codeApply(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
await applyCode(message.content);
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler.registerHandler('code_apply', codeApply);
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { messageHandler } from './messageHandler';
|
||||
|
||||
|
||||
|
||||
export async function applyCodeFile(text: string) {
|
||||
if (vscode.window.visibleTextEditors.length > 1) {
|
||||
vscode.window.showErrorMessage(`There are more then one visible text editors. Please close all but one and try again.`);
|
||||
const validVisibleTextEditors = vscode.window.visibleTextEditors.filter(editor => editor.viewColumn !== undefined);
|
||||
|
||||
if (validVisibleTextEditors.length > 1) {
|
||||
vscode.window.showErrorMessage(`2There are more then one visible text editors. Please close all but one and try again.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const editor = vscode.window.visibleTextEditors[0];
|
||||
const editor = validVisibleTextEditors[0];
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
@ -25,9 +25,9 @@ export async function applyCodeFile(text: string) {
|
||||
});
|
||||
}
|
||||
|
||||
async function codeFileApply(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
export async function codeFileApply(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
await applyCodeFile(message.content);
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler.registerHandler('code_file_apply', codeFileApply);
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
import * as vscode from 'vscode';
|
||||
import CommandManager from '../command/commandManager';
|
||||
import {messageHandler} from './messageHandler';
|
||||
|
||||
|
||||
async function convertCommand(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
export async function convertCommand(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
const newText = await CommandManager.getInstance().processText(message.text);
|
||||
panel.webview.postMessage({ command: 'convertCommand', result: newText });
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler.registerHandler('convertCommand', convertCommand);
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
import * as vscode from 'vscode';
|
||||
import DtmWrapper from '../toolwrapper/dtm';
|
||||
import {messageHandler} from './messageHandler';
|
||||
|
||||
|
||||
async function doCommit(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
export async function doCommit(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
const dtmWrapper = new DtmWrapper();
|
||||
|
||||
const commitResult = await dtmWrapper.commit(message.content);
|
||||
@ -15,5 +14,4 @@ async function doCommit(message: any, panel: vscode.WebviewPanel): Promise<void>
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler.registerHandler('doCommit', doCommit);
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
import * as vscode from 'vscode';
|
||||
import DevChat, { LogOptions } from '../toolwrapper/devchat';
|
||||
import {messageHandler} from './messageHandler';
|
||||
|
||||
|
||||
async function historyMessages(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
export async function historyMessages(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
const devChat = new DevChat();
|
||||
|
||||
const logOptions: LogOptions = message.options || {};
|
||||
@ -12,5 +11,4 @@ async function historyMessages(message: any, panel: vscode.WebviewPanel): Promis
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler.registerHandler('historyMessages', historyMessages);
|
||||
|
||||
|
@ -1,10 +1,24 @@
|
||||
import './addContext';
|
||||
import './codeApply';
|
||||
import './codeFileApply';
|
||||
import './convertCommand';
|
||||
import './doCommit';
|
||||
import './historyMessages';
|
||||
import './regCommandList';
|
||||
import './regContextList';
|
||||
import './sendMessage';
|
||||
import './showDiff';
|
||||
import { messageHandler } from './messageHandler';
|
||||
import { codeApply } from './codeApply';
|
||||
import { codeFileApply } from './codeFileApply';
|
||||
import { convertCommand } from './convertCommand';
|
||||
import { doCommit } from './doCommit';
|
||||
import { historyMessages } from './historyMessages';
|
||||
import { regCommandList } from './regCommandList';
|
||||
import { regContextList } from './regContextList';
|
||||
import { sendMessage } from './sendMessage';
|
||||
import { blockApply } from './showDiff';
|
||||
import { showDiff } from './showDiff';
|
||||
import { addConext } from './addContext';
|
||||
|
||||
messageHandler.registerHandler('addContext', addConext);
|
||||
messageHandler.registerHandler('code_apply', codeApply);
|
||||
messageHandler.registerHandler('code_file_apply', codeFileApply);
|
||||
messageHandler.registerHandler('convertCommand', convertCommand);
|
||||
messageHandler.registerHandler('doCommit', doCommit);
|
||||
messageHandler.registerHandler('historyMessages', historyMessages);
|
||||
messageHandler.registerHandler('regCommandList', regCommandList);
|
||||
messageHandler.registerHandler('regContextList', regContextList);
|
||||
messageHandler.registerHandler('sendMessage', sendMessage);
|
||||
messageHandler.registerHandler('block_apply', blockApply);
|
||||
messageHandler.registerHandler('show_diff', showDiff);
|
@ -1,13 +1,12 @@
|
||||
import * as vscode from 'vscode';
|
||||
import CommandManager from '../command/commandManager';
|
||||
import {messageHandler} from './messageHandler';
|
||||
|
||||
|
||||
async function regCommandList(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
export async function regCommandList(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
const commandList = CommandManager.getInstance().getCommandList();
|
||||
panel.webview.postMessage({ command: 'regCommandList', result: commandList });
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler.registerHandler('regCommandList', regCommandList);
|
||||
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
import * as vscode from 'vscode';
|
||||
import ChatContextManager from '../context/contextManager';
|
||||
import {messageHandler} from './messageHandler';
|
||||
|
||||
|
||||
async function regContextList(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
export async function regContextList(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
const contextList = ChatContextManager.getInstance().getContextList();
|
||||
panel.webview.postMessage({ command: 'regContextList', result: contextList });
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler.registerHandler('regContextList', regContextList);
|
||||
|
||||
|
@ -4,7 +4,6 @@ import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import DevChat from '../toolwrapper/devchat';
|
||||
import CommandManager from '../command/commandManager';
|
||||
import {messageHandler} from './messageHandler';
|
||||
|
||||
|
||||
// Add this function to messageHandler.ts
|
||||
@ -69,7 +68,7 @@ function getInstructionFiles(): string[] {
|
||||
|
||||
let lastPromptHash: string | undefined;
|
||||
|
||||
async function sendMessage(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
export async function sendMessage(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
const devChat = new DevChat();
|
||||
|
||||
const newText2 = await CommandManager.getInstance().processText(message.text);
|
||||
@ -104,5 +103,5 @@ async function sendMessage(message: any, panel: vscode.WebviewPanel): Promise<vo
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler.registerHandler('sendMessage', sendMessage);
|
||||
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
import * as vscode from 'vscode';
|
||||
import {messageHandler} from './messageHandler';
|
||||
import * as path from 'path';
|
||||
import { createTempSubdirectory } from '../util/commonUtil';
|
||||
|
||||
|
||||
export async function diffView(code: string) {
|
||||
if (vscode.window.visibleTextEditors.length > 1) {
|
||||
const validVisibleTextEditors = vscode.window.visibleTextEditors.filter(editor => editor.viewColumn !== undefined);
|
||||
|
||||
if (validVisibleTextEditors.length > 1) {
|
||||
vscode.window.showErrorMessage(`There are more then one visible text editors. Please close all but one and try again.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const editor = vscode.window.visibleTextEditors[0];
|
||||
const editor = validVisibleTextEditors[0];
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
@ -46,15 +47,14 @@ export async function diffView(code: string) {
|
||||
}
|
||||
|
||||
|
||||
async function showDiff(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
export async function showDiff(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
diffView(message.content);
|
||||
return;
|
||||
}
|
||||
|
||||
async function blockApply(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
export async function blockApply(message: any, panel: vscode.WebviewPanel): Promise<void> {
|
||||
diffView(message.content);
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler.registerHandler('block_apply', blockApply);
|
||||
messageHandler.registerHandler('show_diff', showDiff);
|
||||
|
||||
|
@ -26,14 +26,10 @@ export default class ChatPanel {
|
||||
|
||||
// Create a new webview panel
|
||||
private static createWebviewPanel(extensionUri: vscode.Uri): vscode.WebviewPanel {
|
||||
const column = vscode.window.activeTextEditor
|
||||
? vscode.window.activeTextEditor.viewColumn
|
||||
: undefined;
|
||||
|
||||
return vscode.window.createWebviewPanel(
|
||||
'chatPanel',
|
||||
'Chat',
|
||||
column || vscode.ViewColumn.One,
|
||||
vscode.ViewColumn.Beside,
|
||||
{
|
||||
enableScripts: true,
|
||||
localResourceRoots: [vscode.Uri.joinPath(extensionUri, 'dist')],
|
||||
|
@ -108,10 +108,10 @@ class DevChat {
|
||||
const devchatConfig = {
|
||||
model: openaiModel,
|
||||
provider: llmModel,
|
||||
"tokens-per-prompt": tokensPerPrompt,
|
||||
OpenAI: {
|
||||
temperature: openaiTemperature,
|
||||
stream: openaiStream,
|
||||
"tokens-per-prompt": tokensPerPrompt
|
||||
}
|
||||
}
|
||||
// write to config file
|
||||
|
Loading…
x
Reference in New Issue
Block a user