Skip to content

Commit f5070c8

Browse files
update
1 parent 1cd9045 commit f5070c8

File tree

17 files changed

+99
-14
lines changed

17 files changed

+99
-14
lines changed

packages/cli/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable import/export */
2+
13
export * from "./components/DiffView";
24

35
export * from "@git-diff-view/core";

packages/core/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,10 @@ export declare class DiffParser {
456456
export declare const DefaultDiffExpansionStep = 40;
457457
export declare const _cacheMap: Cache$1<string, File$1>;
458458
export declare const changeDefaultComposeLength: (compose: number) => void;
459+
/**
460+
* Change the maximum length of a line to ignore line diff.
461+
*/
462+
export declare const changeMaxLengthToIgnoreLineDiff: (length: number) => void;
459463
export declare const checkCurrentLineIsHidden: (diffFile: DiffFile, lineNumber: number, side: SplitSide) => {
460464
split: boolean;
461465
unified: boolean;
@@ -466,6 +470,7 @@ export declare const disableCache: () => void;
466470
export declare const getCurrentComposeLength: () => number;
467471
export declare const getEnableFastDiffTemplate: () => boolean;
468472
export declare const getLang: (fileName: string) => string;
473+
export declare const getMaxLengthToIgnoreLineDiff: () => number;
469474
export declare const getPlainDiffTemplate: ({ diffLine, rawLine, operator, }: {
470475
diffLine: DiffLine;
471476
rawLine: string;
@@ -537,6 +542,7 @@ export declare const processTransformForFile: (content: string) => string;
537542
export declare const processTransformTemplateContent: (content: string) => string;
538543
export declare const resetDefaultComposeLength: () => void;
539544
export declare const resetEnableFastDiffTemplate: () => void;
545+
export declare const resetMaxLengthToIgnoreLineDiff: () => void;
540546
/**
541547
* Resets all transformation functions to their default state and disables transformation.
542548
*

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/export */
12
export * from "./parse";
23
export * from "./file";
34
export * from "./diff-file";

packages/core/src/parse/change-range.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,20 @@ export interface DiffRange {
2525
readonly newLineSymbol?: NewLineSymbol;
2626
}
2727

28-
const maxLength = 1000;
28+
let maxLengthToIgnoreLineDiff = 1000;
29+
30+
/**
31+
* Change the maximum length of a line to ignore line diff.
32+
*/
33+
export const changeMaxLengthToIgnoreLineDiff = (length: number) => {
34+
maxLengthToIgnoreLineDiff = length;
35+
};
36+
37+
export const resetMaxLengthToIgnoreLineDiff = () => {
38+
maxLengthToIgnoreLineDiff = 1000;
39+
};
40+
41+
export const getMaxLengthToIgnoreLineDiff = () => maxLengthToIgnoreLineDiff;
2942

3043
/** Get the maximum position in the range. */
3144
function rangeMax(range: IRange["range"]): number {
@@ -58,7 +71,7 @@ function commonLength(
5871
}
5972

6073
function isInValidString(s: string) {
61-
return s.trim().length === 0 || s.length >= maxLength;
74+
return s.trim().length === 0 || s.length >= maxLengthToIgnoreLineDiff;
6275
}
6376

6477
function checkNewLineSymbolChange(

packages/core/src/parse/diff-parse.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ export class DiffParser {
137137
* some file content may have multiple line without any character
138138
* such as
139139
* ```
140-
*
141-
*
142-
*
140+
*
141+
*
142+
*
143143
* +
144144
* +
145145
* ```

packages/core/src/parse/diff-tool.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { diffChanges, relativeChanges } from "./change-range";
32
import { DiffLineType, DiffLine } from "./diff-line";
43
import { DiffHunkExpansionType } from "./raw-diff";

packages/file/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,10 @@ export declare class DiffParser {
454454
export declare const DefaultDiffExpansionStep = 40;
455455
export declare const _cacheMap: Cache$1<string, File$1>;
456456
export declare const changeDefaultComposeLength: (compose: number) => void;
457+
/**
458+
* Change the maximum length of a line to ignore line diff.
459+
*/
460+
export declare const changeMaxLengthToIgnoreLineDiff: (length: number) => void;
457461
export declare const checkCurrentLineIsHidden: (diffFile: DiffFile, lineNumber: number, side: SplitSide) => {
458462
split: boolean;
459463
unified: boolean;
@@ -464,6 +468,7 @@ export declare const disableCache: () => void;
464468
export declare const getCurrentComposeLength: () => number;
465469
export declare const getEnableFastDiffTemplate: () => boolean;
466470
export declare const getLang: (fileName: string) => string;
471+
export declare const getMaxLengthToIgnoreLineDiff: () => number;
467472
export declare const getPlainDiffTemplate: ({ diffLine, rawLine, operator, }: {
468473
diffLine: DiffLine;
469474
rawLine: string;
@@ -535,6 +540,7 @@ export declare const processTransformForFile: (content: string) => string;
535540
export declare const processTransformTemplateContent: (content: string) => string;
536541
export declare const resetDefaultComposeLength: () => void;
537542
export declare const resetEnableFastDiffTemplate: () => void;
543+
export declare const resetMaxLengthToIgnoreLineDiff: () => void;
538544
/**
539545
* Resets all transformation functions to their default state and disables transformation.
540546
*

packages/lowlight/src/lang.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export function _getAST(
209209
_theme?: "light" | "dark"
210210
) {
211211
if (__DEV__) {
212-
console.warn('This is a type helper function, do not call it directly.');
212+
console.warn("This is a type helper function, do not call it directly.");
213213
}
214214
return {} as DiffAST;
215215
}

packages/react/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,10 @@ export declare class DiffParser {
454454
export declare const DefaultDiffExpansionStep = 40;
455455
export declare const _cacheMap: Cache$1<string, File$1>;
456456
export declare const changeDefaultComposeLength: (compose: number) => void;
457+
/**
458+
* Change the maximum length of a line to ignore line diff.
459+
*/
460+
export declare const changeMaxLengthToIgnoreLineDiff: (length: number) => void;
457461
export declare const checkCurrentLineIsHidden: (diffFile: DiffFile, lineNumber: number, side: SplitSide) => {
458462
split: boolean;
459463
unified: boolean;
@@ -464,6 +468,7 @@ export declare const disableCache: () => void;
464468
export declare const getCurrentComposeLength: () => number;
465469
export declare const getEnableFastDiffTemplate: () => boolean;
466470
export declare const getLang: (fileName: string) => string;
471+
export declare const getMaxLengthToIgnoreLineDiff: () => number;
467472
export declare const getPlainDiffTemplate: ({ diffLine, rawLine, operator, }: {
468473
diffLine: DiffLine;
469474
rawLine: string;
@@ -535,6 +540,7 @@ export declare const processTransformForFile: (content: string) => string;
535540
export declare const processTransformTemplateContent: (content: string) => string;
536541
export declare const resetDefaultComposeLength: () => void;
537542
export declare const resetEnableFastDiffTemplate: () => void;
543+
export declare const resetMaxLengthToIgnoreLineDiff: () => void;
538544
/**
539545
* Resets all transformation functions to their default state and disables transformation.
540546
*

packages/react/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable import/export */
2+
13
export * from "./components/DiffView";
24

35
export * from "@git-diff-view/core";

0 commit comments

Comments
 (0)