Skip to content

Commit

Permalink
lens only show when there is space
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelneale committed Oct 10, 2024
1 parent 9d5c360 commit 573db42
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,27 @@ export function activate(context: vscode.ExtensionContext) {

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 [];
}
const codeLens = new vscode.CodeLens(editor.selection, {
}
// 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];
}
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 Down

0 comments on commit 573db42

Please sign in to comment.