verticalperlinediffhandleroptions
This commit is contained in:
parent
765b51a261
commit
0358b3c14a
2 changed files with 21 additions and 7 deletions
|
|
@ -9,6 +9,11 @@ import {
|
|||
} from "./decorations";
|
||||
import type { VerticalDiffCodeLens } from "./manager";
|
||||
|
||||
export interface VerticalPerLineDiffHandlerOptions {
|
||||
input?: string;
|
||||
instant?: boolean;
|
||||
}
|
||||
|
||||
export class VerticalPerLineDiffHandler implements vscode.Disposable {
|
||||
private editor: vscode.TextEditor;
|
||||
private startLine: number;
|
||||
|
|
@ -24,7 +29,7 @@ export class VerticalPerLineDiffHandler implements vscode.Disposable {
|
|||
|
||||
private newLinesAdded = 0;
|
||||
|
||||
public input?: string;
|
||||
public options: VerticalPerLineDiffHandlerOptions;
|
||||
|
||||
constructor(
|
||||
startLine: number,
|
||||
|
|
@ -39,13 +44,13 @@ export class VerticalPerLineDiffHandler implements vscode.Disposable {
|
|||
accept: boolean,
|
||||
) => void,
|
||||
private readonly refreshCodeLens: () => void,
|
||||
input?: string,
|
||||
options: VerticalPerLineDiffHandlerOptions,
|
||||
) {
|
||||
this.currentLineIndex = startLine;
|
||||
this.startLine = startLine;
|
||||
this.endLine = endLine;
|
||||
this.editor = editor;
|
||||
this.input = input;
|
||||
this.options = options;
|
||||
|
||||
this.redDecorationManager = new DecorationTypeRangeManager(
|
||||
redDecorationType,
|
||||
|
|
@ -184,6 +189,11 @@ export class VerticalPerLineDiffHandler implements vscode.Disposable {
|
|||
}
|
||||
|
||||
private updateIndexLineDecorations() {
|
||||
if (this.options.instant) {
|
||||
// We don't show progress on instant apply
|
||||
return;
|
||||
}
|
||||
|
||||
// Highlight the line at the currentLineIndex
|
||||
// And lightly highlight all lines between that and endLine
|
||||
if (this.currentLineIndex - this.newLinesAdded >= this.endLine) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import { getMarkdownLanguageTagForFile } from "core/util";
|
|||
import { DiffLine } from "core";
|
||||
import { streamDiffLines } from "core/edit/streamDiffLines";
|
||||
import * as vscode from "vscode";
|
||||
import { VerticalPerLineDiffHandler } from "./handler";
|
||||
import {
|
||||
VerticalPerLineDiffHandler,
|
||||
VerticalPerLineDiffHandlerOptions,
|
||||
} from "./handler";
|
||||
|
||||
export interface VerticalDiffCodeLens {
|
||||
start: number;
|
||||
|
|
@ -31,7 +34,7 @@ export class VerticalPerLineDiffManager {
|
|||
filepath: string,
|
||||
startLine: number,
|
||||
endLine: number,
|
||||
input?: string,
|
||||
options: VerticalPerLineDiffHandlerOptions,
|
||||
) {
|
||||
if (this.filepathToHandler.has(filepath)) {
|
||||
this.filepathToHandler.get(filepath)?.clear(false);
|
||||
|
|
@ -46,7 +49,7 @@ export class VerticalPerLineDiffManager {
|
|||
this.filepathToCodeLens,
|
||||
this.clearForFilepath.bind(this),
|
||||
this.refreshCodeLens,
|
||||
input,
|
||||
options,
|
||||
);
|
||||
this.filepathToHandler.set(filepath, handler);
|
||||
return handler;
|
||||
|
|
@ -201,6 +204,7 @@ export class VerticalPerLineDiffManager {
|
|||
filepath,
|
||||
startLine,
|
||||
endLine,
|
||||
{},
|
||||
);
|
||||
|
||||
if (!diffHandler) {
|
||||
|
|
@ -334,7 +338,7 @@ export class VerticalPerLineDiffManager {
|
|||
filepath,
|
||||
startLine,
|
||||
endLine,
|
||||
input,
|
||||
{ input },
|
||||
);
|
||||
|
||||
if (!diffHandler) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue