🚧 starting work on vertical diffs
This commit is contained in:
parent
5c55e655ee
commit
2817efb016
5 changed files with 37 additions and 7 deletions
|
|
@ -5,7 +5,7 @@ import * as vscode from "vscode";
|
|||
|
||||
import { ideProtocolClient } from "./activation/activate";
|
||||
import { debugPanelWebview, getSidebarContent } from "./debugPanel";
|
||||
import { acceptDiffCommand, rejectDiffCommand } from "./diffs";
|
||||
import { acceptDiffCommand, rejectDiffCommand } from "./diff/horizontal";
|
||||
|
||||
function addHighlightedCodeToContext(edit: boolean) {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { getConfigJsonPath } from "core/util/paths";
|
|||
import { readFileSync } from "fs";
|
||||
import * as vscode from "vscode";
|
||||
import { debugPanelWebview, getSidebarContent } from "./debugPanel";
|
||||
import { diffManager } from "./diffs";
|
||||
import { diffManager } from "./diff/horizontal";
|
||||
import { configHandler } from "./loadConfig";
|
||||
import {
|
||||
SuggestionRanges,
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ import * as fs from "fs";
|
|||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import * as vscode from "vscode";
|
||||
import { extensionContext } from "./activation/activate";
|
||||
import { debugPanelWebview } from "./debugPanel";
|
||||
import { getMetaKeyLabel, getPlatform } from "./util/util";
|
||||
import { uriFromFilePath } from "./util/vscode";
|
||||
import { extensionContext } from "../activation/activate";
|
||||
import { debugPanelWebview } from "../debugPanel";
|
||||
import { getMetaKeyLabel, getPlatform } from "../util/util";
|
||||
import { uriFromFilePath } from "../util/vscode";
|
||||
|
||||
interface DiffInfo {
|
||||
originalFilepath: string;
|
||||
30
extensions/vscode/src/diff/vertical.ts
Normal file
30
extensions/vscode/src/diff/vertical.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
interface DiffBlock {
|
||||
startLine: number;
|
||||
endLine: number;
|
||||
replacement: string[];
|
||||
}
|
||||
|
||||
function linesMatch(lineA: string, lineB: string): boolean {
|
||||
return lineA === lineB;
|
||||
}
|
||||
|
||||
function matchLine(newLine: string, oldLines: string[]): number {
|
||||
let matchIndex = -1;
|
||||
for (let i = 0; i < oldLines.length; i++) {
|
||||
if (linesMatch(newLine, oldLines[i])) {
|
||||
matchIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return matchIndex;
|
||||
}
|
||||
|
||||
async function* streamDiffBlocks(
|
||||
newLinesStream: AsyncGenerator<string>,
|
||||
oldCode: string
|
||||
): AsyncGenerator<DiffBlock> {}
|
||||
|
||||
// But you also want to stream between the diff blocks.
|
||||
// So...not only do you want to stream DiffBlocks
|
||||
// Next is stream lines: {line: string, type: "match" | ""}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import * as vscode from "vscode";
|
||||
import { DIFF_DIRECTORY, diffManager } from "../diffs";
|
||||
import { DIFF_DIRECTORY, diffManager } from "../diff/horizontal";
|
||||
import { editorSuggestionsLocked, editorToSuggestions } from "../suggestions";
|
||||
import { getMetaKeyLabel } from "../util/util";
|
||||
import { getExtensionUri } from "../util/vscode";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue