Skip to content

Commit 3b6347a

Browse files
authored
Merge pull request #19 from square/codelens-remove
removing codelens and adding in option to show diff view
2 parents 3df95f3 + 01b1ae5 commit 3b6347a

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "goose-vscode",
3-
"version": "0.0.14",
3+
"version": "0.0.15",
44
"publisher": "michaelneale",
55
"icon": "goose-icon.png",
66
"main": "./out/extension.js",
@@ -42,6 +42,11 @@
4242
"type": "string",
4343
"default": "goose session start",
4444
"description": "Default command to be executed in Goose terminal."
45+
},
46+
"goose.openDiffEditorAfterGooseEdits": {
47+
"type": "boolean",
48+
"default": false,
49+
"description": "Open the diff editor after Goose has made edits."
4550
}
4651
}
4752
},

src/extension.ts

+21-21
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import * as path from 'path';
55
import { execSync } from 'child_process';
66

77
let gooseTerminal: vscode.Terminal | undefined;
8-
const terminalName = '🪿 goose chat 🪿';
8+
const terminalName = '\u2728 goose chat \u2728';
99

1010
export function activate(context: vscode.ExtensionContext) {
1111

12-
1312
// Check if goose CLI is installed
1413
const config = vscode.workspace.getConfiguration('goose');
1514
let defaultCommand = config.get('defaultCommand', "goose session start");
@@ -87,31 +86,30 @@ export function activate(context: vscode.ExtensionContext) {
8786
}
8887
editor.document.save();
8988
getTerminal().sendText(textToAskGoose);
89+
90+
// Check config for opening diff editor after Goose edits
91+
const openDiffAfterEdit = config.get('openDiffEditorAfterGooseEdits', false);
92+
if (openDiffAfterEdit) {
93+
// Watch for changes in the active text editor
94+
const watcher = vscode.workspace.createFileSystemWatcher(filePath);
95+
watcher.onDidChange(() => {
96+
vscode.commands.executeCommand('workbench.view.scm');
97+
watcher.dispose(); // Stop watching after opening SCM view
98+
});
99+
}
90100
});
91101

92102
context.subscriptions.push(sendToGooseDisposable);
93103

94-
95-
// Register code lens provider
96-
vscode.languages.registerCodeLensProvider('*', {
97-
provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken) {
98-
const editor = vscode.window.activeTextEditor;
99-
if (!editor) {
100-
return [];
101-
}
102-
// Check for a blank line above the selection
103-
const line = editor.selection.start.line - 1;
104-
if (line < 0 || document.lineAt(line).isEmptyOrWhitespace) {
105-
const codeLens = new vscode.CodeLens(editor.selection, {
106-
command: 'extension.sendToGoose',
107-
title: '🪿 Ask Goose 🪿'
108-
});
109-
return [codeLens];
104+
// Completion suggestion: ask goose (general) d
105+
vscode.languages.registerCodeActionsProvider('*', {
106+
provideCodeActions(document: vscode.TextDocument, range: vscode.Range, context: vscode.CodeActionContext, token: vscode.CancellationToken) {
107+
const codeAction = new vscode.CodeAction('Ask goose to edit', vscode.CodeActionKind.QuickFix);
108+
codeAction.command = { command: 'extension.sendToGoose', title: 'Ask goose to edit it' };
109+
return [codeAction];
110110
}
111-
return [];
112-
}
113111
});
114-
112+
115113
// Completion suggestion: ask Goose to explain it
116114
vscode.languages.registerCodeActionsProvider('*', {
117115
provideCodeActions(document: vscode.TextDocument, range: vscode.Range, context: vscode.CodeActionContext, token: vscode.CancellationToken) {
@@ -122,6 +120,7 @@ export function activate(context: vscode.ExtensionContext) {
122120
});
123121

124122

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

217216
}
218217

218+

0 commit comments

Comments
 (0)