Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 875659c

Browse files
committed
docs: warning for large text comparison
1 parent 14d63d6 commit 875659c

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@ Vue diff viewer plugin
1515
* [props](#props)
1616
- [Custom theme](#custom-theme)
1717
- [Extend languages](#extend-languages)
18+
- [Large text comparison](#large-text-comparison)
1819

1920
## Introduction
2021

2122
<img src="https://user-images.githubusercontent.com/25652218/104784360-7520e600-57cb-11eb-8abc-ce81dd309e05.png" alt="screenshot" style="max-width:100%;">
2223

2324
You can see the difference between the two codes with the `vue-diff` plugin.
24-
This plugin dependent on <a href="https://github.com/kpdecker/jsdiff">diff</a> and <a href="https://github.com/highlightjs/highlight.js/">highlight.js</a>, shows similar results to other diff viewers (e.g., Github Desktop).
25+
This plugin dependent on <a href="https://github.com/JackuB/diff-match-patch">diff-match-patch</a> and <a href="https://github.com/highlightjs/highlight.js/">highlight.js</a>, shows similar results to other diff viewers (e.g., Github Desktop).
2526
Here is the <a href="https://hoiheart.github.io/vue-diff/demo/index.html" target="_blank" style="font-size: 1.2em; text-decoration: underline;">demo</a>
2627

2728
## Features
2829

2930
* [x] Support split / unified mode
3031
* [x] Support multiple languages and can be extended
3132
* [X] Support two themes (dark / light) and can be customized
33+
* [ ] Virtual scroll for large text comparison
3234
* [ ] Support IE11 (IE 11 support for Vue@3 is still pending)
3335

3436
## Install plugin
@@ -145,4 +147,8 @@ VueDiff.hljs.registerLanguage('yaml', yaml)
145147
app.use(VueDiff)
146148
```
147149

148-
> <a href="https://github.com/highlightjs/highlight.js/blob/master/SUPPORTED_LANGUAGES.md">Check supported languages of Highlight.js</a>
150+
> <a href="https://github.com/highlightjs/highlight.js/blob/master/SUPPORTED_LANGUAGES.md">Check supported languages of Highlight.js</a>
151+
152+
## Large text comparison
153+
154+
⚠️ It's still hard to compare large texts. Virtual scroll for Vue3 must be created or found.

src/Diff.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ export default defineComponent({
5757
() => props.prev,
5858
() => props.current
5959
], () => {
60-
lines.value = renderLines(props.mode, props.prev, props.current)
60+
const render = renderLines(props.mode, props.prev, props.current)
61+
62+
if (render.length > 1000) {
63+
console.warn('Comparison of many lines is not recommended because rendering delays occur.')
64+
}
65+
66+
lines.value = render
6167
}, { immediate: true })
6268
6369
return { lines }

src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const getSplitLines = (diffsMap: Array<Diffs>): Array<Lines> => {
7979
}
8080
})
8181

82-
return result.slice(0, 100) // todo debounce
82+
return result
8383
}
8484

8585
/**
@@ -125,7 +125,7 @@ const getUnifiedLines = (diffsMap: Array<Diffs>): Array<Lines> => {
125125
})
126126
})
127127

128-
return result.slice(0, 100) // todo debounce
128+
return result
129129
}
130130

131131
/**

0 commit comments

Comments
 (0)