fix(est): combine quantity text edits
This commit is contained in:
@@ -101,6 +101,17 @@ def test_quantity_document_edit_across_character_styles_preserves_tags():
|
||||
assert result == {"same": True, "tags": True}
|
||||
|
||||
|
||||
def test_quantity_document_edit_across_styles_and_separate_marker():
|
||||
script = r"""const q=require('./tools/est-test/native-quantity.cjs'),w=require('./tools/est-test/export-quantity.cjs');
|
||||
const doc='<cs nr=1/><cs nr=2/><div><c nr=1/>abc<c nr=2/>def<begin Tag=2 wpsty=[[Name:"r000001";]]/>6<end Tag=2/></div>';
|
||||
const old=q.fromWpt('A','문서',doc,[],{}),edited=structuredClone(old);
|
||||
edited.rows[0].LineData=edited.rows[0].LineData.replace('bcde','변경').replace('6','12');
|
||||
const next=w.editDocument(doc,old,edited),again=q.fromWpt('A','문서',next,[],{}),tags=x=>x.match(/<[^>]*>/g);
|
||||
process.stdout.write(JSON.stringify({same:JSON.stringify(again)===JSON.stringify(edited),tags:JSON.stringify(tags(doc))===JSON.stringify(tags(next))}));"""
|
||||
result = json.loads(subprocess.check_output(["node", "-e", script], cwd=ROOT).decode("utf-8"))
|
||||
assert result == {"same": True, "tags": True}
|
||||
|
||||
|
||||
def test_multiple_quantity_text_segments_preserve_original_tags_when_sample_exists():
|
||||
sample = Path("C:/Dasansoft/Est Plus 2/Data/ProjectData/main.estx")
|
||||
if not sample.exists():
|
||||
|
||||
@@ -121,7 +121,9 @@ function editDocument(text, oldSheet, sheet) {
|
||||
if (previous[i] === next[i]) continue;
|
||||
previous[i] = next[i];
|
||||
const updated = { ...current, LineData: previous.join("") };
|
||||
const patched = editRun(candidate, current, updated, parse);
|
||||
const patched =
|
||||
editRun(candidate, current, updated, parse) ||
|
||||
editStyledRuns(candidate, current, updated, parse);
|
||||
if (!patched) break;
|
||||
candidate = patched;
|
||||
current = updated;
|
||||
|
||||
Reference in New Issue
Block a user