Skip to content
30 changes: 27 additions & 3 deletions core/nextEdit/DocumentHistoryTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ export class DocumentHistoryTracker {
const documentHistory = this.documentContentHistoryMap.get(documentPath);

if (!astHistory || !documentHistory) {
console.error(`Document ${documentPath} not found in AST tracker`);
const lowerPath = documentPath.toLowerCase();
if (
!lowerPath.endsWith(".yaml") &&
!lowerPath.endsWith(".yml") &&
!lowerPath.endsWith(".json") &&
!lowerPath.endsWith(".md")
) {
console.error(`Document ${documentPath} not found in AST tracker`);
}
this.addDocument(documentPath, documentContent, ast);
return; // Early return - document was added with initial state
}
Expand All @@ -82,7 +90,15 @@ export class DocumentHistoryTracker {
const astHistory = this.documentAstMap.get(documentPath);

if (!astHistory) {
console.error(`Document ${documentPath} not found in AST tracker`);
const lowerPath = documentPath.toLowerCase();
if (
!lowerPath.endsWith(".yaml") &&
!lowerPath.endsWith(".yml") &&
!lowerPath.endsWith(".json") &&
!lowerPath.endsWith(".md")
) {
console.error(`Document ${documentPath} not found in AST tracker`);
}
return null;
}
if (astHistory.length === 0) {
Expand All @@ -105,7 +121,15 @@ export class DocumentHistoryTracker {
const documentHistory = this.documentContentHistoryMap.get(documentPath);

if (!documentHistory) {
console.error(`Document ${documentPath} not found in AST tracker`);
const lowerPath = documentPath.toLowerCase();
if (
!lowerPath.endsWith(".yaml") &&
!lowerPath.endsWith(".yml") &&
!lowerPath.endsWith(".json") &&
!lowerPath.endsWith(".md")
) {
console.error(`Document ${documentPath} not found in AST tracker`);
}
return null;
}
if (documentHistory.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.intellij.ide.starter.plugins.PluginConfigurator
import com.intellij.ide.starter.project.NoProject
import com.intellij.ide.starter.runner.Starter
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.assertTrue
import java.io.File
import kotlin.time.Duration.Companion.seconds

Expand All @@ -32,14 +31,32 @@ class Autocomplete {
}
codeEditor {
keyboard {
enterText("TEST_USER_MESSAGE_0")
space()
escape() // close any popups
enter()
enter()
enter()
}
wait(2.seconds)
keyboard {
tab()
var success = false
for (i in 1..10) {
keyboard {
enterText("TEST_USER_MESSAGE_0")
space()
}
wait(2.seconds)
keyboard {
tab()
}
if (text.contains("TEST_LLM_RESPONSE_0")) {
success = true
break
}
keyboard {
enter()
}
}
if (!success) {
throw Exception("DEBUG_TEXT: ${text.take(500)}")
}
assertTrue(text.contains("TEST_LLM_RESPONSE_0"))
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions extensions/vscode/src/activation/activate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ export async function activateExtension(context: vscode.ExtensionContext) {
"config-yaml-schema.json",
).toString();

try {
await yamlConfig.update(
"schemas",
{
...yamlSchemas,
[newPath]: [yamlMatcher],
},
vscode.ConfigurationTarget.Global,
);
} catch (error) {
console.error(
"Failed to register Continue config.yaml schema, most likely, YAML extension is not installed",
error,
);
const yamlExtension = vscode.extensions.getExtension("redhat.vscode-yaml");
if (yamlExtension) {
try {
await yamlConfig.update(
"schemas",
{
...yamlSchemas,
[newPath]: [yamlMatcher],
},
vscode.ConfigurationTarget.Global,
);
} catch (error) {
console.error("Failed to register Continue config.yaml schema", error);
}
}

const api = new VsCodeContinueApi(vscodeExtension);
Expand Down
26 changes: 16 additions & 10 deletions gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,14 @@ function TipTapEditorInner(props: TipTapEditorProps) {
}
if (result) {
const [_, dataUrl] = result;
const { schema } = editor.state;
const node = schema.nodes.image.create({ src: dataUrl });
const tr = editor.state.tr.insert(0, node);
editor.view.dispatch(tr);
editor
.chain()
.focus()
.insertContent({
type: "image",
attrs: { src: dataUrl },
})
.run();
}
});
event.preventDefault();
Expand Down Expand Up @@ -287,12 +291,14 @@ function TipTapEditorInner(props: TipTapEditorProps) {
}
if (result) {
const [_, dataUrl] = result;
const { schema } = editor.state;
const node = schema.nodes.image.create({ src: dataUrl });
editor.commands.command(({ tr }) => {
tr.insert(0, node);
return true;
});
editor
.chain()
.focus()
.insertContent({
type: "image",
attrs: { src: dataUrl },
})
.run();
}
});
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ export function createEditorConfig(options: {
if (!model) return;
const items = event.clipboardData?.items;
if (items) {
for (const item of items) {
for (let i = 0; i < items.length; i++) {
const item = items[i];
const file = item.getAsFile();
file &&
modelSupportsImages(
Expand All @@ -178,7 +179,7 @@ export function createEditorConfig(options: {
const node = schema.nodes.image.create({
src: dataUrl,
});
const tr = view.state.tr.insert(0, node);
const tr = view.state.tr.replaceSelectionWith(node);
view.dispatch(tr);
},
);
Expand Down
Loading