File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -163,21 +163,22 @@ def main(
163163 for details in blocks
164164 ]
165165
166- match_until_index = 0
166+ last_matching_index : int | None = None
167167 for index , existing_page_block in enumerate (iterable = page .children ):
168168 if index < len (blocks ) and existing_page_block == block_objs [index ]:
169- match_until_index = index
169+ last_matching_index = index
170170 else :
171171 break
172172
173173 click .echo (
174174 message = (
175- f"Matching blocks until index { match_until_index } for page "
175+ f"Matching blocks until index { last_matching_index } for page "
176176 f"'{ title } '"
177177 ),
178178 )
179- for existing_page_block in page .children [match_until_index + 1 :]:
179+ delete_start_index = (last_matching_index or - 1 ) + 1
180+ for existing_page_block in page .children [delete_start_index :]:
180181 existing_page_block .delete ()
181182
182- page .append (blocks = block_objs [match_until_index + 1 :])
183+ page .append (blocks = block_objs [delete_start_index :])
183184 click .echo (message = f"Updated existing page: '{ title } ' ({ page .url } )" )
You can’t perform that action at this time.
0 commit comments