From dba54c90a122644577002439e98d4940a93ed7a6 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 28 May 2025 12:41:08 -0700 Subject: [PATCH] disable diff snippets in jetbrains --- core/autocomplete/snippets/getAllSnippets.ts | 45 +++++++++++++------- core/autocomplete/util/HelperVars.ts | 5 ++- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/core/autocomplete/snippets/getAllSnippets.ts b/core/autocomplete/snippets/getAllSnippets.ts index dce9c9ff4..4446df85a 100644 --- a/core/autocomplete/snippets/getAllSnippets.ts +++ b/core/autocomplete/snippets/getAllSnippets.ts @@ -1,4 +1,4 @@ -import { IDE } from "../../index"; +import { IDE, IdeInfo } from "../../index"; import { findUriInDirs } from "../../util/uri"; import { ContextRetrievalService } from "../context/ContextRetrievalService"; import { GetLspDefinitionsFunction } from "../types"; @@ -112,13 +112,22 @@ const getClipboardSnippets = async ( const getDiffSnippets = async ( ide: IDE, + ideInfo: IdeInfo | undefined, ): Promise => { - const currentTimestamp = ide.getLastFileSaveTimestamp ? - ide.getLastFileSaveTimestamp() : - Math.floor(Date.now() / 10000) * 10000; // Defaults to update once in every 10 seconds + if (ideInfo?.ideType !== "vscode") { + // Disabling for non-vscode IDEs for now + // See https://github.com/continuedev/continue/issues/4130 + // https://github.com/continuedev/continue/issues/5819 + return []; + } + const currentTimestamp = ide.getLastFileSaveTimestamp + ? ide.getLastFileSaveTimestamp() + : Math.floor(Date.now() / 10000) * 10000; // Defaults to update once in every 10 seconds // Check cache first - const cached = diffSnippetsCache.get(currentTimestamp) as AutocompleteDiffSnippet[]; + const cached = diffSnippetsCache.get( + currentTimestamp, + ) as AutocompleteDiffSnippet[]; if (cached) { return cached; @@ -131,13 +140,15 @@ const getDiffSnippets = async ( console.error("Error getting diff for autocomplete", e); } - return diffSnippetsCache.set(currentTimestamp, diff.map((item) => { - return { - content: item, - type: AutocompleteSnippetType.Diff, - }; - })); - + return diffSnippetsCache.set( + currentTimestamp, + diff.map((item) => { + return { + content: item, + type: AutocompleteSnippetType.Diff, + }; + }), + ); }; export const getAllSnippets = async ({ @@ -162,9 +173,13 @@ export const getAllSnippets = async ({ clipboardSnippets, ] = await Promise.all([ racePromise(contextRetrievalService.getRootPathSnippets(helper)), - racePromise(contextRetrievalService.getSnippetsFromImportDefinitions(helper)), - IDE_SNIPPETS_ENABLED ? racePromise(getIdeSnippets(helper, ide, getDefinitionsFromLsp)) : [], - racePromise(getDiffSnippets(ide)), + racePromise( + contextRetrievalService.getSnippetsFromImportDefinitions(helper), + ), + IDE_SNIPPETS_ENABLED + ? racePromise(getIdeSnippets(helper, ide, getDefinitionsFromLsp)) + : [], + racePromise(getDiffSnippets(ide, helper.ideInfo)), racePromise(getClipboardSnippets(ide)), ]); diff --git a/core/autocomplete/util/HelperVars.ts b/core/autocomplete/util/HelperVars.ts index f92ef5a1d..361f7d847 100644 --- a/core/autocomplete/util/HelperVars.ts +++ b/core/autocomplete/util/HelperVars.ts @@ -1,4 +1,4 @@ -import { IDE, TabAutocompleteOptions } from "../.."; +import { IDE, IdeInfo, TabAutocompleteOptions } from "../.."; import { countTokens, pruneLinesFromBottom, @@ -21,6 +21,7 @@ export class HelperVars { lang: AutocompleteLanguageInfo; treePath: AstPath | undefined; workspaceUris: string[] = []; + ideInfo: IdeInfo | undefined; private _fileContents: string | undefined; private _fileLines: string[] | undefined; @@ -43,7 +44,7 @@ export class HelperVars { if (this._fileContents !== undefined) { return; } - + this.ideInfo = await this.ide.getIdeInfo(); this.workspaceUris = await this.ide.getWorkspaceDirs(); this._fileContents =