[anjuta] indentation-c-style: Change get_line_indentation() behaviour.
- From: Carl-Anton Ingmarsson <carlantoni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] indentation-c-style: Change get_line_indentation() behaviour.
- Date: Sat, 25 Jan 2014 12:09:04 +0000 (UTC)
commit 56b09c2d7f371ee2b87e0ed26a75767f8b0ef170
Author: Carl-Anton Ingmarsson <mail carlanton se>
Date: Tue Jan 21 19:04:32 2014 +0100
indentation-c-style: Change get_line_indentation() behaviour.
Change it to not only search on the current line for the first right brace but
search until one is found or a right bracket is found.
This fixes indentation issues with c++11 type return value syntax such as:
auto testFunction()
-> int {
return 5;
}
Where the return type is put on another line different from the end right brace.
https://bugzilla.gnome.org/show_bug.cgi?id=722720
plugins/indentation-c-style/indentation.c | 35 ++++++++++------------------
1 files changed, 13 insertions(+), 22 deletions(-)
---
diff --git a/plugins/indentation-c-style/indentation.c b/plugins/indentation-c-style/indentation.c
index 811f852..81a4d3c 100644
--- a/plugins/indentation-c-style/indentation.c
+++ b/plugins/indentation-c-style/indentation.c
@@ -129,41 +129,32 @@ get_line_indentation (IAnjutaEditor *editor, gint line_num)
line_end = ianjuta_editor_get_line_end_position (editor, line_num, NULL);
+ /* Find first right brace going backwards from end of current line that is before a closing bracket */
while (ianjuta_iterable_previous (line_end, NULL))
{
ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (line_end), 0, NULL);
if (ch == ')')
- right_braces++;
- if (ch == '(')
- left_braces++;
- if (iter_is_newline (line_end, ch))
{
+ right_braces++;
break;
}
+ else if (ch =='}')
+ break;
}
- /* Find the line which contains the left brace matching last right brace on current line */
+ /* Find the line which contains the left brace matching the right brace we found */
if (right_braces > 0)
{
- while (right_braces > left_braces && line_num >= 0)
+ while (ianjuta_iterable_previous (line_end, NULL) && right_braces > left_braces)
{
- line_num--;
- g_object_unref (line_end);
- line_end = ianjuta_editor_get_line_end_position (editor, line_num, NULL);
-
- while (ianjuta_iterable_previous (line_end, NULL))
- {
- ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (line_end), 0, NULL);
- if (ch == ')')
- right_braces++;
- if (ch == '(')
- left_braces++;
- if (iter_is_newline (line_end, ch))
- {
- break;
- }
- }
+ ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (line_end), 0, NULL);
+ if (ch == ')')
+ right_braces++;
+ else if (ch == '(')
+ left_braces++;
}
+
+ line_num = ianjuta_editor_get_line_from_position (editor, line_end, NULL);
}
g_object_unref (line_end);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]