fix(ui): 표 칸 F2 · Enter 는 커서를 글 끝에 — 이어 쓰기(엑셀과 같음)

- 원인: 칸 고치기가 늘 글 전부를 고른 채 열려 F2 뒤에 치면 이어 쓰지 않고 바뀜(3 → F2 → 4 → 4)
- 고침: 표 부품 `edit` 한 곳 — F2 · Enter 는 커서를 글 끝(고름 없음) · 바로 치기는 누른 글자로 바꿈 · 두 번 누르기는 그대로 전부 고름 · M01 `startEdit` 는 안 건드림
- 확인: ORCA 5180 구조물집계표 단위 칸 「m」 — F2 커서 1·1 → 4 → 「m4」 · Enter 같음 · 바로 치기 「7」 · 두 번 누르기 0·1 · 모두 Esc 로 「m」 되돌림 · 저장 안 함

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013zGnt85s95baQ72rhKBCJ4
This commit is contained in:
2026-09-28 23:23:27 +09:00
co-authored by Claude Opus 5.5
parent 9a3645bcaa
commit 4425bd4fea
2 changed files with 30 additions and 3 deletions
+24
View File
@@ -0,0 +1,24 @@
"""표 부품(`ui_template_sheet.ts`) 칸 고치기 — 엑셀처럼 F2 는 커서를 글 끝에(이어 씀).
화면 조작은 ORCA 로 봄 — 여기서는 키마다 고치기 방식이 안 섞이는지만 봄.
"""
from __future__ import annotations
import re
from pathlib import Path
SHEET = Path(__file__).resolve().parents[2] / "ui_template" / "sheet" / "ui_template_sheet.ts"
def test_F2_는_글_끝_바로_치기는_바꿈_두_번_누르기는_그대로():
body = SHEET.read_text(encoding="utf-8")
# Enter · F2 = 글 끝 커서
assert re.search(
r'event\.key === "F2"\) \{\s*event\.preventDefault\(\);\s*edit\(undefined, true\);', body
)
# 바로 치기 = 누른 글자로 바꿈
assert "edit(event.key);" in body
# 두 번 누르기 = 예전대로(글 전부 고름)
assert 'else if (target.closest("td[data-r]")) edit();' in body
assert "box.setSelectionRange(box.value.length, box.value.length)" in body
+6 -3
View File
@@ -244,7 +244,8 @@ export function createSheet(host: HTMLElement, input: SheetDoc, opts: SheetOptio
if (key === KEY_PRICE && typeof got === "string" && col) write(key, col, got);
root.focus({ preventScroll: true });
};
const edit = (initial?: string): void => {
/** 칸 고치기 — 두 번 누르기 = 글 전부 고름 · 바로 치기(initial) = 그 글자로 바꿈 · Enter · F2(atEnd) = 커서를 글 끝에 */
const edit = (initial?: string, atEnd = false): void => {
const sel = state.sel;
const col = sel && colOf(sel.c);
if (!sel || !col) return;
@@ -258,7 +259,9 @@ export function createSheet(host: HTMLElement, input: SheetDoc, opts: SheetOptio
if (!td) return;
startEdit(td, rawText(sel.r, col), (value) => write(sel.r, col, value));
const box = td.querySelector("input");
if (box && initial !== undefined) box.value = initial;
if (!box) return;
if (initial !== undefined) box.value = initial;
if (initial !== undefined || atEnd) box.setSelectionRange(box.value.length, box.value.length);
};
/** 층 이름(머리 층 줄 머리 칸) 고치기 — master */
const editLayer = (th: HTMLElement): void => {
@@ -337,7 +340,7 @@ export function createSheet(host: HTMLElement, input: SheetDoc, opts: SheetOptio
move(0, event.shiftKey ? -1 : 1);
} else if (event.key === "Enter" || event.key === "F2") {
event.preventDefault();
edit();
edit(undefined, true);
} else if (event.key === "Delete" || event.key === "Backspace") {
const col = state.sel && colOf(state.sel.c);
if (state.sel && col && keyEditable(state, state.sel.r, col)) {