[gnome-builder] auto-indent: try to skip past strings and chars when walking backward
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] auto-indent: try to skip past strings and chars when walking backward
- Date: Thu, 16 Oct 2014 23:42:32 +0000 (UTC)
commit c88430ac6e059a606f3a3e84c7fe8b0dbc85d0ed
Author: Christian Hergert <christian hergert me>
Date: Thu Oct 16 16:42:25 2014 -0700
auto-indent: try to skip past strings and chars when walking backward
Not perfect, but it's an incremental start.
I still think we should try to write this differently in that we should
try to build tokens as we walk backwards, or see if we can get clang to
build us a partial translation unit for tokens.
src/auto-indent/gb-source-auto-indenter-c.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/auto-indent/gb-source-auto-indenter-c.c b/src/auto-indent/gb-source-auto-indenter-c.c
index 023e1cf..9451f15 100644
--- a/src/auto-indent/gb-source-auto-indenter-c.c
+++ b/src/auto-indent/gb-source-auto-indenter-c.c
@@ -228,6 +228,24 @@ backward_find_matching_char (GtkTextIter *iter,
{
cur = gtk_text_iter_get_char (iter);
+ if ((cur == '\'') || (cur == '"'))
+ {
+ gunichar strcur = 0;
+
+ while (gtk_text_iter_backward_char (iter))
+ {
+ strcur = gtk_text_iter_get_char (iter);
+ if (strcur == cur)
+ {
+ /* TODO: Check back for escape char */
+ break;
+ }
+ }
+
+ if (strcur != cur)
+ break;
+ }
+
if (cur == match)
{
if (--count == 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]