Skip to content

fix: moveToDocumentEnd 다중 구역 문서 지원 (#784)#808

Closed
oksure wants to merge 2 commits into
edwardkim:develfrom
oksure:contrib/multi-section-doc-end
Closed

fix: moveToDocumentEnd 다중 구역 문서 지원 (#784)#808
oksure wants to merge 2 commits into
edwardkim:develfrom
oksure:contrib/multi-section-doc-end

Conversation

@oksure

@oksure oksure commented May 11, 2026

Copy link
Copy Markdown
Contributor

변경 내용

moveToDocumentEndsectionIndex = 0 하드코드로 다중 구역 문서에서 올바른 문서 끝 위치를 찾지 못하는 문제 수정.

원인

const sec = 0 하드코드 — 다중 구역 문서(예: aift.hwp, 3구역)에서 구역 0의 paragraphCount만 조회하여 마지막 구역의 문단에 도달 불가.

수정

getSectionCount()로 마지막 구역을 찾아 해당 구역의 마지막 문단 끝으로 이동.

const secCount = this.wasm.getSectionCount();
const lastSec = secCount > 0 ? secCount - 1 : 0;

테스트

  • cargo test + cargo clippy -- -D warnings 통과

closes #784

감사합니다.

moveToDocumentEnd/Start 가 sectionIndex=0 하드코드로 다중 구역 문서에서
마지막 구역의 마지막 문단을 찾지 못하는 문제 수정.

getSectionCount() 로 마지막 구역을 찾아 해당 구역의 마지막 문단 끝으로 이동.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 11, 2026 04:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

moveToDocumentEnd가 다중 구역(HWP Section) 문서에서 항상 sectionIndex=0만 기준으로 문서 끝을 계산하던 문제를 수정해, 마지막 구역의 마지막 문단 끝으로 이동하도록 개선하는 PR입니다. 이는 Ctrl/Cmd + ↓ / Ctrl + End 등 “문서 끝 이동” 동작이 다중 구역 문서에서 실패하던 이슈(#784)를 해결하기 위한 변경입니다.

Changes:

  • WASM의 getSectionCount()로 마지막 구역 인덱스를 구한 뒤, 해당 구역의 마지막 문단/오프셋으로 커서를 이동하도록 moveToDocumentEnd 로직 수정
  • paraCount === 0인 경우 fallback 위치의 sectionIndex를 마지막 구역 기준으로 설정

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +477 to +479
const secCount = this.wasm.getSectionCount();
const lastSec = secCount > 0 ? secCount - 1 : 0;
const paraCount = this.wasm.getParagraphCount(lastSec);
Copilot 리뷰 반영: cursor.ts의 moveToDocumentEnd가 호출하는
wasm.getSectionCount()가 WasmBridge에 미정의.
WASM API에는 이미 존재하므로 래퍼만 추가.
@oksure

oksure commented May 11, 2026

Copy link
Copy Markdown
Contributor Author

Copilot 리뷰 반영 (e90eba1): WasmBridge에 getSectionCount() 래퍼 추가

edwardkim added a commit that referenced this pull request May 11, 2026
작업지시자 시각 검증 영역 영역 발견: Ctrl+↓ 영역 영역 문서 끝 영역 영역 이동
(한 문단씩 이동 기대). PR #746 (Task #260) 영역 영역 매핑 영역 영역
macOS 표준 (Cmd+↑/↓ = 문서 시작/끝) 영역 영역만 정합, 한컴 표준
(Ctrl+↑/↓ = 이전/다음 문단) 영역 영역 어긋남.

본 정정:
- cursor.ts 영역 영역 `moveToParagraphBoundary(direction)` 신규
  - 본문 경로: 현재 문단 charOffset > 0 영역 영역 시작 영역 영역 / 0 영역 영역
    이전·다음 문단 시작 영역 영역 / 구역 경계 영역 영역 인접 구역 정합
  - 표 셀 경로: cellParaIndex 이동 (셀 내부 문단 경계)
  - atLineEnd = false 초기화
- input-handler-keyboard.ts 영역 영역 ArrowUp/Down 분기:
  - macOS Cmd+↑/↓ (e.metaKey && !e.ctrlKey) = 문서 시작/끝 (macOS 표준 보존)
  - Windows/Linux Ctrl+↑/↓ = moveToParagraphBoundary (한컴 표준)
edwardkim added a commit that referenced this pull request May 11, 2026
@oksure — Issue #784 (PR #746 시각 검증 중 발견된 오랜 잠재 결함):
moveToDocumentEnd 의 const sec = 0 하드코드 → 다중 구역 문서 (aift.hwp 3 구역)
에서 잘못된 위치로 cursor rect 미발견 오류.

본질 (2 commits):
- WasmBridge.getSectionCount() TypeScript 래퍼 추가 (WASM 측 이미 노출)
- moveToDocumentEnd 의 sec=0 하드코드를 getSectionCount()-1 로 정정
  + 빈 문서 폴백 (secCount > 0 ? secCount - 1 : 0)

함께 정리 — 자기 정정 commit (f2ab6e0):
작업지시자 시각 검증 중 발견 — Ctrl+↓ 가 한 문단씩 이동이 아니라 문서 끝으로 이동
(PR #746 매핑이 macOS 표준만 정합, 한컴 표준 어긋남).
cursor.ts 에 moveToParagraphBoundary 신규 + input-handler-keyboard.ts 분기:
- macOS Cmd+↑/↓ (e.metaKey && !e.ctrlKey) = 문서 시작/끝 (macOS 표준 보존)
- Windows/Linux Ctrl+↑/↓ = 이전/다음 문단 (한컴 표준)
- 본문/표 셀 양 경로 + 구역 경계 정합

자기 검증: tsc + cargo test ALL GREEN, WASM 재빌드 불필요 (TypeScript 단일)
시각 판정: 작업지시자 인터랙션 검증 ✅ 통과
  - aift.hwp Ctrl+End 콘솔 오류 부재 + 마지막 구역 마지막 문단 끝
  - Ctrl+↓ 한 문단씩 이동 정상

별 Issue 로 분리 후속:
- 빈 문단 캐럿 미표시 (마우스 클릭 + 화살표 진입 모두 — 본 PR 무관 기존 결함)

CI: ✅ Build & Test + CodeQL (js-ts/python/rust) + Canvas visual diff
@edwardkim

Copy link
Copy Markdown
Owner

@oksure 머지 완료 (commit ca729bdc).

본질 (다중 구역 moveToDocumentEnd 정정) 정합. WasmBridge getSectionCount() 래퍼 추가 + lastSec 도출 + 빈 문서 폴백 가드 정확.

본 PR 시각 검증 중 발견 — PR #746 (Task #260) 의 Ctrl/Cmd+↑/↓ 매핑이 macOS 표준 (Cmd+↑/↓ = 문서 시작/끝) 만 정합, 한컴 표준 (Ctrl+↑/↓ = 이전/다음 문단) 어긋남. 본 PR 머지 cycle 에 자기 정정 commit 함께 적용:

  • cursor.ts moveToParagraphBoundary(direction) 신규 — 본문/표 셀 양 경로 + 구역 경계 정합
  • input-handler-keyboard.ts ArrowUp/Down 분기:
    • macOS Cmd+↑/↓ (e.metaKey && !e.ctrlKey) = 문서 시작/끝 (macOS 표준 보존)
    • Windows/Linux Ctrl+↑/↓ = 이전/다음 문단 (한컴 표준)

별 Issue 분리 후속: 빈 문단 캐럿 미표시 — 본 PR 무관 기존 결함, 마우스 클릭 + 화살표 진입 모두 동일 본질.

자기 검증 tsc + cargo test ALL GREEN, 작업지시자 인터랙션 검증 통과 (aift.hwp Ctrl+End + Ctrl+↓ 한 문단씩 이동).

수고하셨습니다.

@edwardkim edwardkim closed this May 11, 2026
edwardkim added a commit that referenced this pull request May 11, 2026
- mydocs/pr/archives/pr_808_review.md (다중 구역 정정 + 충돌 분석)
- mydocs/pr/archives/pr_808_report.md (옵션 A 처리 결과 + Ctrl+↑/↓ 자기 정정 + Issue #837 분리)
- mydocs/orders/20260511.md PR #808 행 추가

별 Issue #837 분리 — 빈 문단 캐럿 미표시 (본 PR 무관 기존 결함)
edwardkim added a commit that referenced this pull request May 11, 2026
PR #808 (commit `ca729bdc`) 영역 영역 wasm-bridge.ts:231 영역 영역 `getSectionCount` 이미 추가됨.
PR #811 영역 영역 같은 메서드 영역 영역 다시 추가 (cherry-pick auto-merge 영역 영역 두 메서드 모두 보존됨).

PR #808 측 (라인 231 `this.doc?.getSectionCount() ?? 0`) 영역 보존 + PR #811 측 (라인 409-411) 영역 제거.
edwardkim added a commit that referenced this pull request May 11, 2026
@oksure — Issue #220 (한컴 F5/F3 블록 선택) 영역 4단계 정합. 5단계 영역 영역 문장 단계 영역
별 Issue 분리 후속.

본질 (2 PR commits + 1 정정 commit):
- cursor.ts (+85): _blockSelectionMode + _expandPhase 상태 + enterBlockSelectionMode /
  exitBlockSelectionMode / expandSelection 메서드 + isWordChar / findWordAt 헬퍼
  (Hangul AC00-D7AF + Hangul Jamo 3131-318E + Digit + Latin)
- input-handler-keyboard.ts (+30/-2): F5 토글 (본문/셀 isInCell() 분기) + F3 확장
  + Escape 분기
- Copilot 리뷰 반영 (59a01de): enterBlockSelectionMode anchor 강제 설정
  (this.anchor = { ...this.position })

F3 4단계 확장 (Issue #220 5단계 영역 영역 문장 단계 누락):
- F3 1회: 단어 (findWordAt)
- F3 2회: 문단 전체
- F3 3회: 구역 전체
- F3 4회: 문서 전체 (phase 4 cap)

본 환경 충돌 수동 해결 (1 파일):
- cursor.ts 파일 끝 영역 영역 PR #794 (findWordBoundaryForward/Backward, Alt+Arrow
  단어 이동) + PR #811 (findWordAt, F3 단어 선택) 두 유틸 양측 보존

정정 commit (dc6aa7a):
- wasm-bridge.ts 영역 영역 getSectionCount 중복 정의 제거 (PR #808 의 라인 231 보존,
  PR #811 영역 영역 추가본 제거)

자기 검증: tsc + cargo test ALL GREEN, WASM 재빌드 불필요 (TypeScript 단일)
시각 판정: 작업지시자 인터랙션 검증 ✅ 통과 (F5 본문/셀 + F3 4단계 + 회귀 부재)
CI: ✅ Build & Test + CodeQL + Canvas visual diff

별 Issue 후속 — F3 문장 단계 (Issue #220 5단계 영역 영역 문장 단계)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants