# File lib/rbreadline.rb, line 5640
  def _rl_vi_done_inserting()
    if (@_rl_vi_doing_insert)

      # The `C', `s', and `S' commands set this.
      rl_end_undo_group()
      # Now, the text between rl_undo_list->next->start and
      # rl_undo_list->next->end is what was inserted while in insert
      # mode.  It gets copied to VI_INSERT_BUFFER because it depends
      # on absolute indices into the line which may change (though they
      # probably will not).
      @_rl_vi_doing_insert = 0
      _rl_vi_save_insert(@rl_undo_list.next)
      @vi_continued_command = 1
    else
      if ((@_rl_vi_last_key_before_insert == 'i' || @_rl_vi_last_key_before_insert == 'a') && @rl_undo_list)
        _rl_vi_save_insert(@rl_undo_list)

        # XXX - Other keys probably need to be checked.
      elsif (@_rl_vi_last_key_before_insert == 'C')
        rl_end_undo_group()
      end
      while (@_rl_undo_group_level > 0)
        rl_end_undo_group()
      end
      @vi_continued_command = 0
    end
  end