[latexila] Comment lines: more robust
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Comment lines: more robust
- Date: Sun, 5 Feb 2012 11:31:01 +0000 (UTC)
commit d83756baf38ee0055fe36432157f9b0db0f67062
Author: SÃbastien Wilmet <swilmet src gnome org>
Date: Sun Feb 5 12:14:55 2012 +0100
Comment lines: more robust
It's not a good idea to use TextIter?. It's safer to have another
boolean variable that is true when the TextIter is set.
Using TextIter? can give some errors like this:
expected âstruct GtkTextIter *â but argument is of type âstruct
GtkTextIter **â
src/document.vala | 5 +++--
src/document_structure.vala | 14 ++++++++++----
2 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/document.vala b/src/document.vala
index ca26631..96cf73b 100644
--- a/src/document.vala
+++ b/src/document.vala
@@ -395,12 +395,13 @@ public class Document : Gtk.SourceBuffer
}
// comment the lines between start_iter and end_iter included
- public void comment_between (TextIter start_iter, TextIter? end_iter)
+ public void comment_between (TextIter start_iter, TextIter end_iter,
+ bool end_iter_set = true)
{
int start_line = start_iter.get_line ();
int end_line = start_line;
- if (end_iter != null)
+ if (end_iter_set)
end_line = end_iter.get_line ();
TextIter cur_iter;
diff --git a/src/document_structure.vala b/src/document_structure.vala
index 136a05a..7c66cef 100644
--- a/src/document_structure.vala
+++ b/src/document_structure.vala
@@ -803,17 +803,21 @@ public class DocumentStructure : GLib.Object
-1);
TextIter start_iter;
- TextIter? end_iter = null;
+ TextIter end_iter = {};
+ bool end_iter_set = false;
_doc.get_iter_at_mark (out start_iter, start_mark);
if (end_mark != null)
+ {
_doc.get_iter_at_mark (out end_iter, end_mark);
+ end_iter_set = true;
+ }
/* comment a simple item */
if (! Structure.is_section (type))
{
- _doc.comment_between (start_iter, end_iter);
+ _doc.comment_between (start_iter, end_iter, end_iter_set);
return true;
}
@@ -838,6 +842,7 @@ public class DocumentStructure : GLib.Object
{
bool end_of_file;
end_iter = get_end_document_iter (out end_of_file);
+ end_iter_set = true;
go_one_line_backward = ! end_of_file;
}
@@ -848,15 +853,16 @@ public class DocumentStructure : GLib.Object
-1);
_doc.get_iter_at_mark (out end_iter, end_mark);
+ end_iter_set = true;
}
if (go_one_line_backward)
{
if (! end_iter.backward_line ())
- end_iter = null;
+ end_iter_set = false;
}
- _doc.comment_between (start_iter, end_iter);
+ _doc.comment_between (start_iter, end_iter, end_iter_set);
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]