Skip to content

Commit

Permalink
Merge pull request #18 from square/codelens-fix
Browse files Browse the repository at this point in the history
lens only show when there is space
  • Loading branch information
michaelneale authored Oct 10, 2024
2 parents 9d5c360 + 573db42 commit 02dfad2
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 02dfad2

Please sign in to comment.