Skip to content

Commit

Permalink
DEV2-4266 fireevent on command (#1368)
Browse files Browse the repository at this point in the history
* DEV2-4266 fireevent on command

* limit lenght
  • Loading branch information
dimacodota authored Nov 19, 2023
1 parent 3637cab commit 738656d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ const CODE_LENS_ACTIONS = [

const VALID_SYMBOLS = [SymbolKind.Function, SymbolKind.Method];

const MAX_LINES = 2500;

export default class ChatCodeLensProvider implements CodeLensProvider {
// eslint-disable-next-line class-methods-use-this
public async provideCodeLenses(
document: TextDocument
): Promise<CodeLens[] | undefined> {
if (document.lineCount > MAX_LINES) {
return [];
}
const documnetSymbols = await commands.executeCommand<
(SymbolInformation & DocumentSymbol)[]
>("vscode.executeDocumentSymbolProvider", document.uri);
Expand Down
13 changes: 13 additions & 0 deletions src/tabnineChatWidget/extensionCommands/codeLens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import ChatCodeLensProvider from "./ChatCodeLensProvider";
import ChatViewProvider from "../../ChatViewProvider";
import tabnineExtensionProperties from "../../../globals/tabnineExtensionProperties";
import { fireEvent } from "../../../binary/requests/requests";

const languagesFilter = [
{ language: "javascript" },
Expand Down Expand Up @@ -42,6 +43,12 @@ export default function registerChatCodeLens(
commands.registerCommand(
"tabnine.chat.commands.any",
(range: Range, intent: string) => {
void fireEvent({
name: "chat-lens-action",
intent,
language: window.activeTextEditor?.document.languageId,
});

const editor = window.activeTextEditor;
if (editor) {
const newSelection = new Selection(range.start, range.end);
Expand All @@ -51,6 +58,12 @@ export default function registerChatCodeLens(
}
),
commands.registerCommand("tabnine.chat.commands.ask", (range: Range) => {
void fireEvent({
name: "chat-lens-action",
intent: "ask-question",
language: window.activeTextEditor?.document.languageId,
});

const editor = window.activeTextEditor;
if (editor) {
const newSelection = new Selection(range.start, range.end);
Expand Down

0 comments on commit 738656d

Please sign in to comment.