fix: searchAllText API 추가 — rhwpDev.search() 다중 매치 수정 (#692)#814
Closed
oksure wants to merge 2 commits into
Closed
fix: searchAllText API 추가 — rhwpDev.search() 다중 매치 수정 (#692)#814oksure wants to merge 2 commits into
oksure wants to merge 2 commits into
Conversation
) search_text_native의 단건 검색은 strict greater-than 비교(charOffset > from_char)로 위치 0의 매치를 누락하며, 반복 호출 시 wrap-around/후진 가드의 복잡성으로 인해 다중 매치 수집이 불완전했음. searchAllText WASM API를 추가하여 search_all() 결과를 일괄 반환하도록 하고, rhwpDev.search()를 단건 반복 호출 → 일괄 호출로 교체하여 문제 해결. 변경: - Rust: search_all_text_native() — 본문/셀 포함 전체 매치 배열 반환 - WASM: searchAllText(query, caseSensitive, includeCells) 바인딩 - TS: SearchHit 타입 + wasm-bridge searchAllText() 메서드 - TS: rhwp-dev.ts search()를 searchAllText() 기반으로 재작성 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
WASM 레벨에서 문서 전체 텍스트 검색 결과(모든 매치)를 한 번에 반환하는 searchAllText API를 추가하고, 이를 기반으로 DEV 도구(rhwpDev.search())의 다중 매치 수집 불완전 문제(#692)를 우회/해결하는 PR입니다.
Changes:
- Rust
DocumentCore에 전체 매치 배열을 JSON으로 반환하는search_all_text_native()추가 - WASM 바인딩(
searchAllText) 및 Studio 쪽 브릿지/타입(SearchHit) 추가 - DEV 모드에서
rhwpDev디버깅 툴킷 초기화 및search()를 일괄 검색 기반으로 재작성
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/wasm_api.rs | WASM에 searchAllText 엔트리포인트 노출 |
| src/document_core/queries/search_query.rs | 전체 검색 JSON 배열 반환 API 추가 (include_cells 지원) |
| rhwp-studio/src/main.ts | DEV 모드에서 initRhwpDev(wasm) 호출 추가 |
| rhwp-studio/src/core/wasm-bridge.ts | searchAllText() 브릿지 메서드 추가 |
| rhwp-studio/src/core/types.ts | 전체 검색 결과 타입 SearchHit 추가 |
| rhwp-studio/src/core/rhwp-dev.ts | DEV 전용 rhwpDev 디버깅 툴킷 신규 추가 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const eventBus = new EventBus(); | ||
|
|
||
| // E2E 테스트용 전역 노출 (개발 모드 전용) | ||
| // E2E 테스트용 전역 노출 (개발 모드 전���) |
Comment on lines
+189
to
+214
| /// 문서 전체 검색 (모든 매치 반환) | ||
| /// | ||
| /// 본문 문단의 모든 매치를 배열로 반환한다. 표/글상자 내부 포함 여부는 | ||
| /// include_cells 파라미터로 결정. | ||
| /// | ||
| /// 반환: JSON `[{"sec":0,"para":1,"charOffset":5,"length":3,"cellContext":...}, ...]` | ||
| pub fn search_all_text_native( | ||
| &self, | ||
| query: &str, | ||
| case_sensitive: bool, | ||
| include_cells: bool, | ||
| ) -> Result<String, HwpError> { | ||
| if query.is_empty() { | ||
| return Ok("[]".to_string()); | ||
| } | ||
|
|
||
| let all_hits = search_all(self, query, case_sensitive); | ||
| if all_hits.is_empty() { | ||
| return Ok("[]".to_string()); | ||
| } | ||
|
|
||
| let hits: Vec<&SearchHit> = if include_cells { | ||
| all_hits.iter().collect() | ||
| } else { | ||
| all_hits.iter().filter(|h| h.cell_context.is_none()).collect() | ||
| }; |
Comment on lines
+571
to
+583
| /** 전체 검색 결과 항목 */ | ||
| export interface SearchHit { | ||
| sec: number; | ||
| para: number; | ||
| charOffset: number; | ||
| length: number; | ||
| cellContext?: { | ||
| parentPara: number; | ||
| ctrlIdx: number; | ||
| cellIdx: number; | ||
| cellPara: number; | ||
| }; | ||
| } |
- main.ts: '전���' → '전용' (UTF-8 인코딩 깨짐 수정) - types.ts: SearchHit.para/cellContext 필드에 JSDoc 추가 (셀 매치 시 para=parentPara임을 명시) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
edwardkim
added a commit
that referenced
this pull request
May 11, 2026
devel 측 영역 영역 이미 `initRhwpDev` import 존재 (라인 24). PR #814 cherry-pick auto-merge 영역 영역 라인 29 영역 영역 중복 import 추가됨. 라인 29 중복 제거 + 라인 24 보존.
edwardkim
added a commit
that referenced
this pull request
May 11, 2026
…매치 근본 정정 @oksure — Issue #692 (PR #684 영역 4 가드 적용 후에도 미정합, 작업지시자 직접 검증 영역 영역 발견): rhwpDev.search(text) 반복 호출 방식 영역 다중 매치 불완전. 근본 결함: - search_text_native 단건 검색 영역 영역 h.char_offset > from_char (strict greater-than) → 위치 0 영역 시작 매치 누락 - 반복 호출 방식 영역 영역 wrap-around / 후진 / 반복 횟수 한계 종료 조건 정합 부재 본질 (6 files, +202/-0): - Rust: search_all_text_native (+45, search_all 내부 함수 영역 일괄 반환) + searchAllText WASM 바인딩 (+13) - TypeScript: SearchHit 인터페이스 (+16, sec/para/charOffset/length/cellContext) + searchAllText 래퍼 (+5) + rhwp-dev.ts 재작성 (+121, 반복 호출 → 일괄 호출) + main.ts DEV 모드 initRhwpDev 호출 (+2) 리뷰 반영 commit (2f4ba94): 인코딩 깨짐 수정 + SearchHit.para 의미 문서화. 본 환경 충돌 수동 해결 + 정정 commit (4f763f1): - rhwp-dev.ts: incoming (PR) 측 우선 — searchAllText 기반 재작성 (PR #684 의 4 가드 + SearchResult 인터페이스 폐기) - main.ts: initRhwpDev 중복 import 제거 (cherry-pick auto-merge 결과 정정) - types.ts / wasm-bridge.ts / search_query.rs / wasm_api.rs: auto-merge 자기 검증: tsc + cargo test/clippy ALL GREEN, WASM 4.6 MB 재빌드 시각 판정: 작업지시자 DEV mode 콘솔 검증 ✅ 통과
Owner
|
@oksure 머지 완료 (commit PR #684 의 4 가드 (wrapped + 가드 + 반복 횟수 + 후진 가드) 한계 정확 진단 — 본 환경 충돌 5 파일 수동 해결 + 정정 commit 1건:
자기 검증 tsc + cargo test/clippy ALL GREEN + WASM 4.6 MB 재빌드. 작업지시자 DEV mode 콘솔 검증 통과 (rhwpDev.search 일괄 매치 + 위치 0 매치 포함 정합). 수고하셨습니다. |
edwardkim
added a commit
that referenced
this pull request
May 11, 2026
- mydocs/pr/archives/pr_814_review.md (searchAllText 분석 + 5 파일 충돌) - mydocs/pr/archives/pr_814_report.md (옵션 A 처리 결과 + 근본 정정 패턴) - mydocs/orders/20260511.md PR #814 행 추가 후속 요청 — rhwpDev.goto(hit) 메서드 별 Issue + 후속 PR
edwardkim
added a commit
that referenced
this pull request
May 11, 2026
PR #814 (commit `306159c3`) 후속 — 작업지시자 요청 영역 영역 SearchHit 영역 영역 캐럿 이동 메서드 추가 + 일반 웹 개발자 영역 영역 도움말 확장. 신규 메서드 — rhwpDev.goto(hit, options?): - SearchHit (rhwpDev.search() 결과) → DocumentPosition 변환 + cursor.moveTo - 셀 컨텍스트 자동 분기 (hit.cellContext 영역 영역 parentParaIndex/controlIndex/ cellIndex/cellParaIndex 매핑) - options.select (기본 true) — hit.length > 0 영역 영역 setAnchor + endPos 영역 영역 이동 영역 영역 매치 영역 영역 선택 - inputHandler.updateCaret() 호출 영역 영역 캐럿 + 자동 스크롤 정합 - __inputHandler 미초기화 영역 영역 warning + false 반환 교육용 help() 확장: - 개요 + 5 메서드 명세 (search/goto/showAllIds/findNearest/help) - 6 사용 예시 (코드 + 주석): 1) 매치 검색 2) 인덱스 영역 영역 이동 + 선택 3) 캐럿만 이동 (select: false) 4) 표 셀 포함 검색 5) 셀 매치 이동 6) 한 줄 패턴 (변수 부재) - SearchHit 구조 명세 - 주의 사항 (초기화 / DEV 모드 한정) - 색상 강조 (제목 파랑/녹색 / 주석 회색 / 주의 빨강) toolkit 로드 메시지 — 한국어 + rhwpDev.help() 영역 영역 강조 안내. 인프라 재사용: - cursor.moveTo / clearSelection / setAnchor (기존) - inputHandler.updateCaret (기존, scrollCaretIntoView 포함) - __inputHandler 전역 노출 (main.ts:203, 기존) 자기 검증: tsc --noEmit ✅ 시각 판정: 작업지시자 검증 통과 (rhwpDev.search → goto 매치 이동 + help() 확장)
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
문제
rhwpDev.search(text)다중 매치 수집이 불완전합니다 (#692).근본 원인:
search_text_native의 단건 검색은h.char_offset > from_char(strict greater-than)으로 비교하여, 위치 0에서 시작하는 매치를 누락합니다. 반복 호출 방식은 wrap-around 가드, 후진 가드 등의 복잡한 종료 조건이 필요하며, 이들이 불완전하여 결과가 미정합됩니다.해결
search_all()내부 함수를 WASM으로 직접 노출하는searchAllTextAPI를 추가하여 모든 매치를 일괄 반환합니다.rhwpDev.search()를 반복 호출 → 일괄 호출로 교체하여 iteration 관련 버그를 근본적으로 제거합니다.변경 사항
search_query.rssearch_all_text_native()메서드 추가 — 본문/셀 포함 여부 선택 가능wasm_api.rssearchAllText(query, caseSensitive, includeCells)WASM 바인딩types.tsSearchHit인터페이스 추가wasm-bridge.tssearchAllText()브릿지 메서드rhwp-dev.tssearch()를searchAllText()기반으로 재작성,includeCells옵션 추가main.tsinitRhwpDev(wasm)호출 추가검증
cargo test전체 통과cargo clippy -- -D warnings경고 없음감사합니다.