@@ -803,6 +803,60 @@ def test_no_strip_normal(self):
803803 assert strip_auto_numbering ("Normal text" ) == ("Normal text" , False )
804804
805805
806+ class TestLocateItemMatchNumbering :
807+ """Regression tests for numbering stripping during item locate."""
808+
809+ def test_boundary_body_match_strips_revised_text (self ):
810+ """When violation_text is stripped by mode, revised_text should be stripped too."""
811+ applier = create_mock_applier ()
812+ para = create_paragraph_xml (
813+ "三防漆涂覆\n 依据文件ADYU0.005.000《三防漆涂覆通用工艺规程》和"
814+ "ADYU2.088.1192ZD6《信息处理组件三防漆涂覆作业指导书》中要求执行。" ,
815+ para_id = "AAAA1111" ,
816+ )
817+ item = create_edit_item (
818+ uuid = "AAAA1111" ,
819+ uuid_end = "AAAA1111" ,
820+ fix_action = "replace" ,
821+ violation_text = (
822+ "h) 三防漆涂覆\n 依据文件ADYU0.005.000《三防漆涂覆通用工艺规程》和"
823+ "ADYU2.088.1192ZD6《信息处理组件三防漆涂覆作业指导书》中要求执行。"
824+ ),
825+ revised_text = (
826+ "h) 三防漆涂覆\n 依据文件ADYU0.005.000《三防漆涂覆通用工艺规程》和"
827+ "ADYU2.088.1192ZD5《信息处理组件三防漆涂覆作业指导书》中要求执行。"
828+ ),
829+ )
830+
831+ # Force fallback route:
832+ # single-para original miss -> numbering variant miss -> boundary_crossed ->
833+ # body segment original miss -> body segment numbering variant hit
834+ search_results = iter ([(- 1 , None ), (- 1 , None ), (- 1 , None ), (0 , None )])
835+ applier ._find_in_runs_with_normalization = lambda runs , text : next (search_results )
836+ applier ._iter_paragraphs_in_range = lambda start_para , uuid_end : iter ([para ])
837+ applier ._collect_runs_info_across_paragraphs = (
838+ lambda start_para , uuid_end : ([], "" , False , "boundary_crossed" )
839+ )
840+ applier ._find_tables_in_range = lambda start_para , uuid_end : []
841+ applier ._is_paragraph_in_table = lambda _para : False
842+ applier ._apply_fallback_comment = lambda * args , ** kwargs : None
843+
844+ context = applier ._locate_item_match (
845+ item = item ,
846+ anchor_para = para ,
847+ violation_text = item .violation_text ,
848+ revised_text = item .revised_text ,
849+ )
850+
851+ assert context ["target_para" ] is para
852+ assert context ["matched_start" ] == 0
853+ assert context ["numbering_stripped" ] is True
854+ assert context ["violation_text" ].startswith ("三防漆涂覆" )
855+ assert context ["revised_text" ].startswith ("三防漆涂覆" )
856+ assert not context ["revised_text" ].startswith ("h) " )
857+ assert "ZD5" in context ["revised_text" ]
858+
859+
806860# ============================================================
807861# Tests: _find_revision_ancestor
808862# ============================================================
0 commit comments