🔍 Update search logic to process all file lines and optimize display updates
This commit is contained in:
@@ -603,14 +603,19 @@ const onSearchInput = debounce(async () => {
|
|||||||
const device = getDevicePerformance();
|
const device = getDevicePerformance();
|
||||||
const chunkSize = device.recommendedChunkSize;
|
const chunkSize = device.recommendedChunkSize;
|
||||||
|
|
||||||
// Process in chunks
|
// Search through ALL fileLines, not just displayLines
|
||||||
for (let i = 0; i < displayLines.value.length; i += chunkSize) {
|
for (let i = 0; i < fileLines.value.length; i += chunkSize) {
|
||||||
const chunk = displayLines.value.slice(i, i + chunkSize);
|
const chunk = fileLines.value.slice(i, i + chunkSize);
|
||||||
|
|
||||||
chunk.forEach((line, idx) => {
|
chunk.forEach((lineContent, idx) => {
|
||||||
const actualIndex = i + idx;
|
const actualIndex = i + idx;
|
||||||
const matches = line.content.toLowerCase().includes(searchTerm);
|
const matches = lineContent.toLowerCase().includes(searchTerm);
|
||||||
displayLines.value[actualIndex].hasMatch = matches;
|
|
||||||
|
// Only update displayLines if it's within the visible range
|
||||||
|
const displayIndex = displayLines.value.findIndex(l => l.lineNumber === actualIndex + 1);
|
||||||
|
if (displayIndex !== -1) {
|
||||||
|
displayLines.value[displayIndex].hasMatch = matches;
|
||||||
|
}
|
||||||
|
|
||||||
if (matches) {
|
if (matches) {
|
||||||
results.push(actualIndex);
|
results.push(actualIndex);
|
||||||
@@ -619,7 +624,7 @@ const onSearchInput = debounce(async () => {
|
|||||||
|
|
||||||
// Update progress
|
// Update progress
|
||||||
operationProgress.value.percent = Math.min(
|
operationProgress.value.percent = Math.min(
|
||||||
((i + chunkSize) / displayLines.value.length) * 100,
|
((i + chunkSize) / fileLines.value.length) * 100,
|
||||||
100
|
100
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user