fix codeblock error

This commit is contained in:
Dallin Romney 2024-12-16 20:12:29 -08:00
parent 59918b3207
commit ab2f6761ee
3 changed files with 20 additions and 3 deletions

View file

@ -12,10 +12,9 @@ export function rifWithContentsToContextItem(
);
const rangeStr = `(${rif.range.start.line + 1}-${rif.range.end.line + 1})`;
const itemName = `${basename} ${rangeStr}`;
return {
content: rif.contents,
name: itemName,
name: `${basename} ${rangeStr}`,
description: `${relativePathOrBasename} ${rangeStr}`, // This is passed to the LLM - do not pass full URI
id: {
providerTitle: "code",

View file

@ -746,9 +746,27 @@ function TipTapEditor(props: TipTapEditorProps) {
if (!props.isMainInput || !editor) {
return;
}
// const rif: RangeInFile & { contents: string } =
// data.rangeInFileWithContents;
// const basename = getBasename(rif.filepath);
// const relativePath = getRelativePath(
// rif.filepath,
// await ideMessenger.ide.getWorkspaceDirs(),
// const rangeStr = `(${rif.range.start.line + 1}-${
// rif.range.end.line + 1
// })`;
// const itemName = `${basename} ${rangeStr}`;
// const item: ContextItemWithId = {
// content: rif.contents,
// name: itemName
// }
const contextItem = rifWithContentsToContextItem(
data.rangeInFileWithContents,
);
console.log(contextItem);
let index = 0;
for (const el of editor.getJSON()?.content ?? []) {
if (el.attrs?.item?.name === contextItem.name) {

View file

@ -71,7 +71,7 @@ async function resolveEditorContent({
}
} else if (p.type === "codeBlock") {
if (p.attrs?.item) {
const contextItem = p.atts.item as ContextItemWithId;
const contextItem = p.attrs.item as ContextItemWithId;
const rif = ctxItemToRifWithContents(contextItem);
// If not editing, include codeblocks in the prompt
// If editing is handled by selectedCode below