This commit is contained in:
Andrew Pareles 2024-11-14 02:09:55 -08:00
parent 799f6c2d16
commit a974a5df69
3 changed files with 9 additions and 4 deletions

View file

@ -1,8 +1,9 @@
import { Range } from 'vscode'; import { Range } from 'vscode';
import { diffLines, Change } from 'diff';
import { Diff } from './registerInlineDiffs'; import { Diff } from './registerInlineDiffs';
import { diffLines } from './react/out/util/diffLines.js'
type Fields = type Fields =
| 'type' | 'type'
| 'originalCode' | 'originalCode'
@ -27,7 +28,7 @@ export type SuggestedEdit = {
export function findDiffs(oldStr: string, newStr: string) { export function findDiffs(oldStr: string, newStr: string) {
// an ordered list of every original line, line added to the new file, and line removed from the old file (order is unambiguous, think about it) // an ordered list of every original line, line added to the new file, and line removed from the old file (order is unambiguous, think about it)
const lineByLineChanges: Change[] = diffLines(oldStr, newStr); const lineByLineChanges = diffLines(oldStr, newStr);
lineByLineChanges.push({ value: '', added: false, removed: false }) // add a dummy so we flush any streaks we haven't yet at the very end (!line.added && !line.removed) lineByLineChanges.push({ value: '', added: false, removed: false }) // add a dummy so we flush any streaks we haven't yet at the very end (!line.added && !line.removed)
let oldFileLineNum: number = 0; let oldFileLineNum: number = 0;

View file

@ -0,0 +1,3 @@
import { diffLines, Change } from 'diff';
export { diffLines, Change }

View file

@ -5,6 +5,7 @@ export default defineConfig({
'./src2/sidebar-tsx/Sidebar.tsx', './src2/sidebar-tsx/Sidebar.tsx',
'./src2/util/sendLLMMessage.tsx', './src2/util/sendLLMMessage.tsx',
'./src2/util/posthog.tsx', './src2/util/posthog.tsx',
'./src2/util/diffLines.tsx',
], ],
outDir: './out', outDir: './out',
format: ['esm'], format: ['esm'],
@ -14,10 +15,10 @@ export default defineConfig({
clean: true, clean: true,
platform: 'browser', platform: 'browser',
target: 'esnext', target: 'esnext',
injectStyle: true, // bundle css into the output file // injectStyle: true, // bundle css into the output file
outExtension: () => ({ js: '.js' }), outExtension: () => ({ js: '.js' }),
// default behavior is to take local files and make them internal (bundle them) and take imports like 'react' and leave them external (don't bundle them), we want the opposite in many ways // default behavior is to take local files and make them internal (bundle them) and take imports like 'react' and leave them external (don't bundle them), we want the opposite in many ways
noExternal: [ // noExternal means we should take these things and make them not external (bundle them into the output file) noExternal: [ // noExternal means we should take these things and make them not external (bundle them into the output file) - anything that doesn't start with a "." needs to be force-flagged as not external
/^(?!\.).*$/ /^(?!\.).*$/
], ],
external: [ // these imports should be kept external ../../../ are external (this is just an optimization so the output file doesn't re-implement functions) external: [ // these imports should be kept external ../../../ are external (this is just an optimization so the output file doesn't re-implement functions)