User utf8 as file code. Copy .chat .
This commit is contained in:
parent
5c7c273b20
commit
da89e38ffa
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import * as fs from 'fs';
|
||||||
import { createTempSubdirectory, getLanguageIdByFileName } from '../util/commonUtil';
|
import { createTempSubdirectory, getLanguageIdByFileName } from '../util/commonUtil';
|
||||||
|
|
||||||
export async function handleFileSelected(fileSelected: string) {
|
export async function handleFileSelected(fileSelected: string) {
|
||||||
@ -12,8 +13,7 @@ export async function handleFileSelected(fileSelected: string) {
|
|||||||
const tempFile = path.join(tempDir, fileName);
|
const tempFile = path.join(tempDir, fileName);
|
||||||
|
|
||||||
// load content in fileSelected
|
// load content in fileSelected
|
||||||
const fileContent = await vscode.workspace.fs.readFile(vscode.Uri.file(fileSelected));
|
const fileContent = fs.readFileSync(fileSelected, 'utf-8');
|
||||||
|
|
||||||
// get the language from fileSelected
|
// get the language from fileSelected
|
||||||
const languageId = await getLanguageIdByFileName(fileSelected);
|
const languageId = await getLanguageIdByFileName(fileSelected);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
import { createChatDirectoryAndCopyInstructionsSync } from './init/chatConfig';
|
|
||||||
import {
|
import {
|
||||||
registerOpenChatPanelCommand,
|
registerOpenChatPanelCommand,
|
||||||
registerAddContextCommand,
|
registerAddContextCommand,
|
||||||
@ -16,9 +16,6 @@ function activate(context: vscode.ExtensionContext) {
|
|||||||
ExtensionContextHolder.context = context;
|
ExtensionContextHolder.context = context;
|
||||||
logger.init(context);
|
logger.init(context);
|
||||||
|
|
||||||
// 创建 .chat 目录并复制 workflows
|
|
||||||
createChatDirectoryAndCopyInstructionsSync(context.extensionUri);
|
|
||||||
|
|
||||||
registerOpenChatPanelCommand(context);
|
registerOpenChatPanelCommand(context);
|
||||||
registerAddContextCommand(context);
|
registerAddContextCommand(context);
|
||||||
registerAskForCodeCommand(context);
|
registerAskForCodeCommand(context);
|
||||||
|
@ -9,6 +9,7 @@ import WebviewManager from './webviewManager';
|
|||||||
import messageHistory from '../util/messageHistory';
|
import messageHistory from '../util/messageHistory';
|
||||||
import CustomCommands from '../command/customCommand';
|
import CustomCommands from '../command/customCommand';
|
||||||
import CommandManager from '../command/commandManager';
|
import CommandManager from '../command/commandManager';
|
||||||
|
import { createChatDirectoryAndCopyInstructionsSync } from '../init/chatConfig';
|
||||||
|
|
||||||
export default class ChatPanel {
|
export default class ChatPanel {
|
||||||
private static _instance: ChatPanel | undefined;
|
private static _instance: ChatPanel | undefined;
|
||||||
@ -17,6 +18,9 @@ export default class ChatPanel {
|
|||||||
private _disposables: vscode.Disposable[] = [];
|
private _disposables: vscode.Disposable[] = [];
|
||||||
|
|
||||||
public static createOrShow(extensionUri: vscode.Uri) {
|
public static createOrShow(extensionUri: vscode.Uri) {
|
||||||
|
// 创建 .chat 目录并复制 workflows
|
||||||
|
createChatDirectoryAndCopyInstructionsSync(extensionUri);
|
||||||
|
|
||||||
const workspaceDir = vscode.workspace.workspaceFolders?.[0].uri.fsPath;
|
const workspaceDir = vscode.workspace.workspaceFolders?.[0].uri.fsPath;
|
||||||
if (workspaceDir) {
|
if (workspaceDir) {
|
||||||
const workflowsDir = path.join(workspaceDir!, '.chat', 'workflows');
|
const workflowsDir = path.join(workspaceDir!, '.chat', 'workflows');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user