Skip to content

plugins/todo: Fix result_info_merge insertion point

When merging the TODO items of a single file back into the model, result_info_merge uses the following algorithm:

  1. Get an iterator into the model's GSequence of TODO items.
  2. Navigate to the first item with the path of the current file. (The items are sorted primarily by path and secondarily by line number.)
  3. While the iterator points to an old item for the current file, remove it, and advance the iterator.
  4. If we removed anything, walk the iterator back one item.
  5. Insert the new items.

This commit removes step 4. The convention in GSequence is that insertions (and g_sequence_move_range, which is what's actually used) are before the destination. So after step 3, the iterator is already at the insertion point.


I've tested this commit under the original conditions outlined in #2197 (closed), and also tested boundary conditions like adding or removing a TODO comment at the beginning or end of the sequence.

Fixes #2197 (closed)

Edited by Will Blankemeyer

Merge request reports