Merge pull request #5879 from continuedev/dallin/disable-git-diff-jetbrains
Disable diff autocomplete snippets in jetbrains
This commit is contained in:
commit
573c6c2e0c
2 changed files with 33 additions and 17 deletions
|
|
@ -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<AutocompleteDiffSnippet[]> => {
|
||||
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)),
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue