fix main merge conflicts
This commit is contained in:
commit
745b97ff0f
22 changed files with 217 additions and 23 deletions
4
.changes/unreleased/Changed-20241213-091505.yaml
Normal file
4
.changes/unreleased/Changed-20241213-091505.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
project: extensions/vscode
|
||||
kind: Changed
|
||||
body: Improved autocomplete in untitled files
|
||||
time: 2024-12-13T09:15:05.552877-08:00
|
||||
4
.changes/unreleased/Fixed-20241213-091454.yaml
Normal file
4
.changes/unreleased/Fixed-20241213-091454.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
project: extensions/vscode
|
||||
kind: Fixed
|
||||
body: Display more mid-line completions
|
||||
time: 2024-12-13T09:14:54.808683-08:00
|
||||
4
.changes/unreleased/Fixed-20241213-091519.yaml
Normal file
4
.changes/unreleased/Fixed-20241213-091519.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
project: extensions/vscode
|
||||
kind: Fixed
|
||||
body: Restored syntax highlighting
|
||||
time: 2024-12-13T09:15:19.485189-08:00
|
||||
|
|
@ -16,6 +16,8 @@ import {
|
|||
streamWithNewLines,
|
||||
} from "./lineStream";
|
||||
|
||||
const STOP_AT_PATTERNS = ["diff --git"];
|
||||
|
||||
export class StreamTransformPipeline {
|
||||
async *transform(
|
||||
generator: AsyncGenerator<string>,
|
||||
|
|
@ -28,7 +30,10 @@ export class StreamTransformPipeline {
|
|||
): AsyncGenerator<string> {
|
||||
let charGenerator = generator;
|
||||
|
||||
charGenerator = stopAtStopTokens(generator, stopTokens);
|
||||
charGenerator = stopAtStopTokens(generator, [
|
||||
...stopTokens,
|
||||
...STOP_AT_PATTERNS,
|
||||
]);
|
||||
charGenerator = stopAtStartOf(charGenerator, suffix);
|
||||
for (const charFilter of helper.lang.charFilters ?? []) {
|
||||
charGenerator = charFilter({
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ export async function testAutocompleteFiltering(
|
|||
const line = prefix.split("\n").length - 1;
|
||||
const character = prefix.split("\n")[line].length;
|
||||
const autocompleteInput: AutocompleteInput = {
|
||||
isUntitledFile: false,
|
||||
completionId: "test-completion-id",
|
||||
filepath: fileUri,
|
||||
pos: {
|
||||
|
|
|
|||
|
|
@ -90,6 +90,17 @@ export function postprocessCompletion({
|
|||
completion = completion.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
// When there is no suffix, Codestral tends to begin with a new line
|
||||
// We do this to avoid double new lines
|
||||
if (
|
||||
suffix.length === 0 &&
|
||||
prefix.endsWith("\n\n") &&
|
||||
completion.startsWith("\n")
|
||||
) {
|
||||
// Remove a single leading \n from the completion
|
||||
completion = completion.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (llm.model.includes("granite")) {
|
||||
|
|
|
|||
|
|
@ -58,6 +58,14 @@ export async function shouldPrefilter(
|
|||
return true;
|
||||
}
|
||||
|
||||
// Don't offer completions when we have no information (untitled file and no file contents)
|
||||
if (
|
||||
helper.filepath.includes("Untitled") &&
|
||||
helper.fileContents.trim() === ""
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if (
|
||||
// helper.options.transform &&
|
||||
// (await shouldLanguageSpecificPrefilter(helper))
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@ import { CompletionOptions } from "../..";
|
|||
import { AutocompleteLanguageInfo } from "../constants/AutocompleteLanguageInfo";
|
||||
import { HelperVars } from "../util/HelperVars";
|
||||
|
||||
import { SnippetPayload } from "../snippets";
|
||||
import {
|
||||
AutocompleteTemplate,
|
||||
getTemplateForModel,
|
||||
} from "./AutocompleteTemplate";
|
||||
import { getStopTokens } from "./getStopTokens";
|
||||
import { SnippetPayload } from "../snippets";
|
||||
import { formatSnippets } from "./formatting";
|
||||
import { getSnippets } from "./filtering";
|
||||
import { getUriPathBasename } from "../../util/uri";
|
||||
import { formatSnippets } from "./formatting";
|
||||
import { getStopTokens } from "./getStopTokens";
|
||||
|
||||
function getTemplate(helper: HelperVars): AutocompleteTemplate {
|
||||
if (helper.options.template) {
|
||||
|
|
@ -62,6 +62,9 @@ export function renderPrompt({
|
|||
// If prefix is manually passed
|
||||
let prefix = helper.input.manuallyPassPrefix || helper.prunedPrefix;
|
||||
let suffix = helper.input.manuallyPassPrefix ? "" : helper.prunedSuffix;
|
||||
if (suffix === "") {
|
||||
suffix = "\n";
|
||||
}
|
||||
|
||||
const reponame = getUriPathBasename(workspaceDirs[0] ?? "myproject");
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ export type RecentlyEditedRange = RangeInFile & {
|
|||
};
|
||||
|
||||
export interface AutocompleteInput {
|
||||
isUntitledFile: boolean;
|
||||
completionId: string;
|
||||
filepath: string;
|
||||
pos: Position;
|
||||
|
|
|
|||
|
|
@ -476,7 +476,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
): AsyncGenerator<string> {
|
||||
const { completionOptions, log } = this._parseCompletionOptions(options);
|
||||
|
||||
const madeUpFimPrompt = `${prefix}<FIM>${suffix}`;
|
||||
const madeUpFimPrompt = `<|fim_prefix|>${prefix}<|fim_suffix|>${suffix}<|fim_middle|>`;
|
||||
if (log) {
|
||||
if (this.writeLog) {
|
||||
await this.writeLog(
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] =
|
|||
"didChangeAvailableProfiles",
|
||||
"setTTSActive",
|
||||
"getWebviewHistoryLength",
|
||||
"getCurrentSessionId",
|
||||
"signInToControlPlane",
|
||||
"openDialogMessage",
|
||||
"docs/suggestions",
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ export type ToWebviewFromIdeOrCoreProtocol = {
|
|||
];
|
||||
setTTSActive: [boolean, void];
|
||||
getWebviewHistoryLength: [undefined, number];
|
||||
getCurrentSessionId: [undefined, string];
|
||||
signInToControlPlane: [undefined, void];
|
||||
openDialogMessage: ["account", void];
|
||||
"docs/suggestions": [PackageDocsResult[], void];
|
||||
|
|
|
|||
14
core/util/findLast.ts
Normal file
14
core/util/findLast.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
export function findLastIndex(
|
||||
arr: any[],
|
||||
criterion: (item: any) => boolean,
|
||||
): number {
|
||||
let lastIndex = -1;
|
||||
|
||||
for (let i = arr.length - 1; i >= 0; i--) {
|
||||
if (criterion(arr[i])) {
|
||||
lastIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return lastIndex;
|
||||
}
|
||||
|
|
@ -5,6 +5,13 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
|
|||
and is generated by [Changie](https://github.com/miniscruff/changie).
|
||||
|
||||
|
||||
Pre-release Changes
|
||||
### Changed
|
||||
* Improved autocomplete in untitled files
|
||||
### Fixed
|
||||
* Display more mid-line completions
|
||||
* Restored syntax highlighting
|
||||
|
||||
## 0.8.62 - 2024-12-10
|
||||
### Added
|
||||
* Tool use
|
||||
|
|
|
|||
28
extensions/vscode/package-lock.json
generated
28
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.243",
|
||||
"version": "0.9.244",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.243",
|
||||
"version": "0.9.244",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
"core": "file:../../core",
|
||||
"cors": "^2.8.5",
|
||||
"dbinfoz": "^0.14.0",
|
||||
"diff": "^7.0.0",
|
||||
"downshift": "^7.6.0",
|
||||
"esbuild": "^0.17.19",
|
||||
"express": "^4.18.2",
|
||||
|
|
@ -4981,9 +4982,9 @@
|
|||
"integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw=="
|
||||
},
|
||||
"node_modules/diff": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz",
|
||||
"integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==",
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-7.0.0.tgz",
|
||||
"integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==",
|
||||
"engines": {
|
||||
"node": ">=0.3.1"
|
||||
}
|
||||
|
|
@ -8858,6 +8859,15 @@
|
|||
"wrap-ansi": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/mocha/node_modules/diff": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz",
|
||||
"integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/mocha/node_modules/minimatch": {
|
||||
"version": "5.1.6",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz",
|
||||
|
|
@ -13165,6 +13175,14 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/uvu/node_modules/diff": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz",
|
||||
"integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==",
|
||||
"engines": {
|
||||
"node": ">=0.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/v8-to-istanbul": {
|
||||
"version": "9.3.0",
|
||||
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"author": "Continue Dev, Inc",
|
||||
"version": "0.9.244",
|
||||
"version": "0.9.245",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
@ -678,6 +678,7 @@
|
|||
"core": "file:../../core",
|
||||
"cors": "^2.8.5",
|
||||
"dbinfoz": "^0.14.0",
|
||||
"diff": "^7.0.0",
|
||||
"downshift": "^7.6.0",
|
||||
"esbuild": "^0.17.19",
|
||||
"express": "^4.18.2",
|
||||
|
|
|
|||
|
|
@ -449,7 +449,6 @@ class VsCodeIde implements IDE {
|
|||
const contents = new TextDecoder().decode(truncatedBytes);
|
||||
return contents;
|
||||
} catch (e) {
|
||||
console.warn("Error reading file", e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import {
|
|||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import * as vscode from "vscode";
|
||||
const Diff = require("diff");
|
||||
|
||||
import { showFreeTrialLoginMessage } from "../util/messages";
|
||||
import { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
|
|
@ -23,6 +24,13 @@ import URI from "uri-js";
|
|||
import type { IDE } from "core";
|
||||
import type { TabAutocompleteModel } from "../util/loadAutocompleteModel";
|
||||
|
||||
interface DiffType {
|
||||
count: number;
|
||||
added: boolean;
|
||||
removed: boolean;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface VsCodeCompletionInput {
|
||||
document: vscode.TextDocument;
|
||||
position: vscode.Position;
|
||||
|
|
@ -100,6 +108,12 @@ export class ContinueCompletionProvider
|
|||
return null;
|
||||
}
|
||||
|
||||
// Don't autocomplete with multi-cursor
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (editor && editor.selections.length > 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// If the text at the range isn't a prefix of the intellisense text,
|
||||
// no completion will be displayed, regardless of what we return
|
||||
if (
|
||||
|
|
@ -189,10 +203,17 @@ export class ContinueCompletionProvider
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Manually pass file contents for unsaved, untitled files
|
||||
if (document.isUntitled) {
|
||||
manuallyPassFileContents = document.getText();
|
||||
}
|
||||
|
||||
// Handle commit message input box
|
||||
let manuallyPassPrefix: string | undefined = undefined;
|
||||
|
||||
const input: AutocompleteInput = {
|
||||
isUntitledFile: document.isUntitled,
|
||||
completionId: uuidv4(),
|
||||
filepath: document.uri.toString(),
|
||||
pos,
|
||||
|
|
@ -248,13 +269,67 @@ export class ContinueCompletionProvider
|
|||
|
||||
// Construct the range/text to show
|
||||
const startPos = selectedCompletionInfo?.range.start ?? position;
|
||||
const completionRange = new vscode.Range(
|
||||
startPos,
|
||||
startPos.translate(0, outcome.completion.length),
|
||||
);
|
||||
let range = new vscode.Range(startPos, startPos);
|
||||
let completionText = outcome.completion;
|
||||
const isSingleLineCompletion = outcome.completion.split("\n").length <= 1;
|
||||
|
||||
if (isSingleLineCompletion) {
|
||||
const lastLineOfCompletionText = completionText.split("\n").pop();
|
||||
const currentText = document
|
||||
.lineAt(startPos)
|
||||
.text.substring(startPos.character);
|
||||
const diffs: DiffType[] = Diff.diffWords(
|
||||
currentText,
|
||||
lastLineOfCompletionText,
|
||||
);
|
||||
|
||||
if (diffPatternMatches(diffs, ["+"])) {
|
||||
// Just insert, we're already at the end of the line
|
||||
} else if (
|
||||
diffPatternMatches(diffs, ["+", "="]) ||
|
||||
diffPatternMatches(diffs, ["+", "=", "+"])
|
||||
) {
|
||||
// The model repeated the text after the cursor to the end of the line
|
||||
range = new vscode.Range(
|
||||
startPos,
|
||||
document.lineAt(startPos).range.end,
|
||||
);
|
||||
} else if (
|
||||
diffPatternMatches(diffs, ["+", "-"]) ||
|
||||
diffPatternMatches(diffs, ["-", "+"])
|
||||
) {
|
||||
// We are midline and the model just inserted without repeating to the end of the line
|
||||
// We want to move the cursor to the end of the line
|
||||
// range = new vscode.Range(
|
||||
// startPos,
|
||||
// document.lineAt(startPos).range.end,
|
||||
// );
|
||||
// // Find the last removed part of the diff
|
||||
// const lastRemovedIndex = findLastIndex(
|
||||
// diffs,
|
||||
// (diff) => diff.removed === true,
|
||||
// );
|
||||
// const lastRemovedContent = diffs[lastRemovedIndex].value;
|
||||
// completionText += lastRemovedContent;
|
||||
} else {
|
||||
// Diff is too complicated, just insert the first added part of the diff
|
||||
// This is the safe way to ensure that it is displayed
|
||||
if (diffs[0]?.added) {
|
||||
completionText = diffs[0].value;
|
||||
} else {
|
||||
// If the first part of the diff isn't an insertion, then the model is
|
||||
// probably rewriting other parts of the line
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Extend the range to the end of the line for multiline completions
|
||||
range = new vscode.Range(startPos, document.lineAt(startPos).range.end);
|
||||
}
|
||||
|
||||
const completionItem = new vscode.InlineCompletionItem(
|
||||
outcome.completion,
|
||||
completionRange,
|
||||
completionText,
|
||||
range,
|
||||
{
|
||||
title: "Log Autocomplete Outcome",
|
||||
command: "continue.logAutocompleteOutcome",
|
||||
|
|
@ -293,3 +368,26 @@ export class ContinueCompletionProvider
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
type DiffPartType = "+" | "-" | "=";
|
||||
|
||||
function diffPatternMatches(
|
||||
diffs: DiffType[],
|
||||
pattern: DiffPartType[],
|
||||
): boolean {
|
||||
if (diffs.length !== pattern.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < diffs.length; i++) {
|
||||
const diff = diffs[i];
|
||||
const diffPartType: DiffPartType =
|
||||
!diff.added && !diff.removed ? "=" : diff.added ? "+" : "-";
|
||||
|
||||
if (diffPartType !== pattern[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -720,9 +720,10 @@ const getCommandsMap: (
|
|||
"continue.applyCodeFromChat": () => {
|
||||
void sidebar.webviewProtocol.request("applyCodeFromChat", undefined);
|
||||
},
|
||||
"continue.toggleFullScreen": () => {
|
||||
"continue.toggleFullScreen": async () => {
|
||||
focusGUI();
|
||||
|
||||
const sessionId = await sidebar.webviewProtocol.request("getCurrentSessionId", undefined);
|
||||
// Check if full screen is already open by checking open tabs
|
||||
const fullScreenTab = getFullScreenTab();
|
||||
|
||||
|
|
@ -743,6 +744,7 @@ const getCommandsMap: (
|
|||
vscode.ViewColumn.One,
|
||||
{
|
||||
retainContextWhenHidden: true,
|
||||
enableScripts: true,
|
||||
},
|
||||
);
|
||||
fullScreenPanel = panel;
|
||||
|
|
@ -755,6 +757,13 @@ const getCommandsMap: (
|
|||
undefined,
|
||||
true,
|
||||
);
|
||||
|
||||
panel.onDidChangeViewState(() => {
|
||||
vscode.commands.executeCommand("continue.newSession");
|
||||
if(sessionId){
|
||||
vscode.commands.executeCommand("continue.focusContinueSessionId", sessionId);
|
||||
}
|
||||
});
|
||||
|
||||
// When panel closes, reset the webview and focus
|
||||
panel.onDidDispose(
|
||||
|
|
@ -767,6 +776,7 @@ const getCommandsMap: (
|
|||
);
|
||||
|
||||
vscode.commands.executeCommand("workbench.action.copyEditorToNewWindow");
|
||||
vscode.commands.executeCommand("workbench.action.closeAuxiliaryBar");
|
||||
},
|
||||
"continue.openConfig": () => {
|
||||
core.invoke("config/openProfile", {
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ export function History() {
|
|||
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
|
||||
const sessionTitle = useAppSelector((state) => state.session.title);
|
||||
|
||||
const minisearch = useRef<MiniSearch>(
|
||||
new MiniSearch({
|
||||
fields: ["title"],
|
||||
|
|
|
|||
|
|
@ -65,8 +65,6 @@ const Layout = () => {
|
|||
|
||||
const showDialog = useAppSelector((state) => state.ui.showDialog);
|
||||
|
||||
const isStreaming = useAppSelector((state) => state.session.isStreaming);
|
||||
|
||||
useWebviewListener(
|
||||
"openDialogMessage",
|
||||
async (message) => {
|
||||
|
|
|
|||
|
|
@ -137,6 +137,14 @@ function useSetup() {
|
|||
[history],
|
||||
);
|
||||
|
||||
useWebviewListener(
|
||||
"getCurrentSessionId",
|
||||
async () => {
|
||||
return sessionId
|
||||
},
|
||||
[sessionId],
|
||||
);
|
||||
|
||||
useWebviewListener("setInactive", async () => {
|
||||
dispatch(setInactive());
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue