MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / find

Function find

src/handlers/quickTools.js:529–562  ·  view source on GitHub ↗

* Finds the next/previous search result * @param {number} skip Number of search results to skip * @param {boolean} backward Whether to search backward

(skip, backward)

Source from the content-addressed store, hash-verified

527 * @param {boolean} backward Whether to search backward
528 */
529function find(skip, backward) {
530 const { $searchInput } = quickTools;
531 const { activeFile } = editorManager;
532
533 // Check if current tab is a terminal
534 if (
535 activeFile &&
536 activeFile.type === "terminal" &&
537 activeFile.terminalComponent
538 ) {
539 activeFile.terminalComponent.search($searchInput.value, skip, backward);
540 } else {
541 const editor = editorManager.editor;
542 const searchValue = getRefValue($searchInput);
543 const query = applySearchQuery(editor, searchValue);
544 if (!query || !query.search || !query.valid) {
545 updateSearchState();
546 return;
547 }
548
549 const normalizedSkip = Number(skip) || 0;
550 if (normalizedSkip === 0 && selectionMatchesQuery(editor, query)) {
551 updateSearchState();
552 return;
553 }
554 const steps = Math.max(1, normalizedSkip);
555 const runCommand = backward ? cmFindPrevious : cmFindNext;
556 for (let i = 0; i < steps; ++i) {
557 if (!runCommand(editor)) break;
558 }
559 }
560
561 updateSearchState();
562}
563
564function updateSearchState() {
565 const MAX_COUNT = 999;

Callers 3

setupHistoryNavigationFunction · 0.70
actionsFunction · 0.70
toggleSearchFunction · 0.70

Calls 5

getRefValueFunction · 0.85
applySearchQueryFunction · 0.85
updateSearchStateFunction · 0.85
selectionMatchesQueryFunction · 0.85
searchMethod · 0.45

Tested by

no test coverage detected