Skip to content

Commit

Permalink
Merge pull request #19 from square/codelens-remove
Browse files Browse the repository at this point in the history
removing codelens and adding in option to show diff view
  • Loading branch information
michaelneale authored Oct 11, 2024
2 parents 3df95f3 + 01b1ae5 commit 3b6347a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "goose-vscode",
"version": "0.0.14",
"version": "0.0.15",
"publisher": "michaelneale",
"icon": "goose-icon.png",
"main": "./out/extension.js",
Expand Down Expand Up @@ -42,6 +42,11 @@
"type": "string",
"default": "goose session start",
"description": "Default command to be executed in Goose terminal."
},
"goose.openDiffEditorAfterGooseEdits": {
"type": "boolean",
"default": false,
"description": "Open the diff editor after Goose has made edits."
}
}
},
Expand Down
42 changes: 21 additions & 21 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import * as path from 'path';
import { execSync } from 'child_process';

let gooseTerminal: vscode.Terminal | undefined;
const terminalName = '🪿 goose chat 🪿';
const terminalName = '\u2728 goose chat \u2728';

export function activate(context: vscode.ExtensionContext) {


// Check if goose CLI is installed
const config = vscode.workspace.getConfiguration('goose');
let defaultCommand = config.get('defaultCommand', "goose session start");
Expand Down Expand Up @@ -87,31 +86,30 @@ export function activate(context: vscode.ExtensionContext) {
}
editor.document.save();
getTerminal().sendText(textToAskGoose);

// Check config for opening diff editor after Goose edits
const openDiffAfterEdit = config.get('openDiffEditorAfterGooseEdits', false);
if (openDiffAfterEdit) {
// Watch for changes in the active text editor
const watcher = vscode.workspace.createFileSystemWatcher(filePath);
watcher.onDidChange(() => {
vscode.commands.executeCommand('workbench.view.scm');
watcher.dispose(); // Stop watching after opening SCM view
});
}
});

context.subscriptions.push(sendToGooseDisposable);


// Register code lens provider
vscode.languages.registerCodeLensProvider('*', {
provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken) {
const editor = vscode.window.activeTextEditor;
if (!editor) {
return [];
}
// Check for a blank line above the selection
const line = editor.selection.start.line - 1;
if (line < 0 || document.lineAt(line).isEmptyOrWhitespace) {
const codeLens = new vscode.CodeLens(editor.selection, {
command: 'extension.sendToGoose',
title: '🪿 Ask Goose 🪿'
});
return [codeLens];
// Completion suggestion: ask goose (general) d
vscode.languages.registerCodeActionsProvider('*', {
provideCodeActions(document: vscode.TextDocument, range: vscode.Range, context: vscode.CodeActionContext, token: vscode.CancellationToken) {
const codeAction = new vscode.CodeAction('Ask goose to edit', vscode.CodeActionKind.QuickFix);
codeAction.command = { command: 'extension.sendToGoose', title: 'Ask goose to edit it' };
return [codeAction];
}
return [];
}
});

// Completion suggestion: ask Goose to explain it
vscode.languages.registerCodeActionsProvider('*', {
provideCodeActions(document: vscode.TextDocument, range: vscode.Range, context: vscode.CodeActionContext, token: vscode.CancellationToken) {
Expand All @@ -122,6 +120,7 @@ export function activate(context: vscode.ExtensionContext) {
});



// Completion suggestion: ask Goose to finish it
vscode.languages.registerCodeActionsProvider('*', {
provideCodeActions(document: vscode.TextDocument, range: vscode.Range, context: vscode.CodeActionContext, token: vscode.CancellationToken) {
Expand Down Expand Up @@ -216,3 +215,4 @@ export function activate(context: vscode.ExtensionContext) {

}


0 comments on commit 3b6347a

Please sign in to comment.