[latexila/structure-actions] Structure: remove _insert_at_end



commit a57df6dc32868824834295a503f1572e71d14ef3
Author: SÃbastien Wilmet <swilmet src gnome org>
Date:   Wed Jun 29 20:26:26 2011 +0200

    Structure: remove _insert_at_end

 src/document_structure.vala |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/src/document_structure.vala b/src/document_structure.vala
index d4c4283..89a17f1 100644
--- a/src/document_structure.vala
+++ b/src/document_structure.vala
@@ -54,7 +54,6 @@ public class DocumentStructure : GLib.Object
     private int _nb_marks = 0;
     private static const string MARK_NAME_PREFIX = "struct_item_";
 
-    private bool _insert_at_end = true;
     private StructureModel _model = null;
 
     private static Regex? _chars_regex = null;
@@ -90,6 +89,8 @@ public class DocumentStructure : GLib.Object
                     new Regex ("^(?P<type>TODO|FIXME)[[:space:]:]*(?P<text>.*)$");
 
                 // the LaTeX command can contain some optional arguments
+                // TODO a better implementation of this regex would be to parse the line
+                // character by character, so we can verify if some chars are escaped.
                 _command_name_regex =
                     new Regex ("^(?P<name>[a-z]+\\*?)[[:space:]]*(\\[[^\\]]*\\][[:space:]]*)*{");
             }
@@ -135,10 +136,6 @@ public class DocumentStructure : GLib.Object
                 _timer.continue ();
         }
 
-        // When parsing all the document at once, the items are always inserted at the end
-        // FIXME still needed?
-        _insert_at_end = true;
-
         int cur_line = _start_parsing_line;
         int nb_lines = _doc.get_line_count ();
         int stop_parsing_line = _start_parsing_line + MAX_NB_LINES_TO_PARSE;
@@ -317,7 +314,6 @@ public class DocumentStructure : GLib.Object
     private string? get_markup_name (string line, int after_backslash_index,
         out int? begin_contents_index = null)
     {
-        // TODO use match_full with start_pos instead
         string after_backslash_text = line.substring (after_backslash_index);
 
         MatchInfo match_info;
@@ -471,15 +467,15 @@ public class DocumentStructure : GLib.Object
         add_item_data (data);
     }
 
-    private void add_item_data (StructData data, bool force_insert_in_middle = false)
+    private void add_item_data (StructData data, bool insert_in_middle = false)
     {
         if (data.text == null)
             data.text = "";
 
-        if (_insert_at_end && ! force_insert_in_middle)
-            _model.add_item_at_end (data);
-        else
+        if (insert_in_middle)
             _model.add_item_in_middle (data);
+        else
+            _model.add_item_at_end (data);
     }
 
     private TextMark create_text_mark_from_iter (TextIter iter)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]