| 562 | } |
| 563 | |
| 564 | function updateSearchState() { |
| 565 | const MAX_COUNT = 999; |
| 566 | const { activeFile, editor } = editorManager; |
| 567 | const { $searchPos, $searchTotal } = quickTools; |
| 568 | |
| 569 | // Check if current tab is a terminal |
| 570 | if (activeFile && activeFile.type === "terminal") { |
| 571 | // For terminal, we can't easily count all matches like in ACE editor |
| 572 | // xterm search addon doesn't provide this information |
| 573 | // So we just show a generic indicator |
| 574 | $searchTotal.textContent = "?"; |
| 575 | $searchPos.textContent = "?"; |
| 576 | return; |
| 577 | } |
| 578 | const query = editor ? getSearchQuery(editor.state) : null; |
| 579 | if (!query || !query.search || !query.valid) { |
| 580 | $searchTotal.textContent = "0"; |
| 581 | $searchPos.textContent = "0"; |
| 582 | return; |
| 583 | } |
| 584 | |
| 585 | const cursor = query.getCursor(editor.state.doc); |
| 586 | let total = 0; |
| 587 | let before = 0; |
| 588 | let limited = false; |
| 589 | const cursorPos = editor.state.selection.main.head; |
| 590 | for (cursor.next(); !cursor.done; cursor.next()) { |
| 591 | total++; |
| 592 | if (cursorPos >= cursor.value.from) { |
| 593 | before = Math.min(total, MAX_COUNT); |
| 594 | } |
| 595 | if (total === MAX_COUNT) { |
| 596 | cursor.next(); |
| 597 | limited = !cursor.done; |
| 598 | break; |
| 599 | } |
| 600 | } |
| 601 | $searchTotal.textContent = limited ? "999+" : String(total); |
| 602 | $searchPos.textContent = String(before); |
| 603 | } |
| 604 | |
| 605 | /** |
| 606 | * Sets the height of the footer |