jaehyun pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=63bff248178a45c9d4bd4a563d7309e14b5cf673

commit 63bff248178a45c9d4bd4a563d7309e14b5cf673
Author: Jaehyun Cho <jae_hyun....@samsung.com>
Date:   Thu Feb 18 01:42:49 2016 +0900

    indent: Fix indentation calculation in line comment
---
 src/lib/indent.c | 33 +++++++++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/src/lib/indent.c b/src/lib/indent.c
index c668515..79a75a7 100644
--- a/src/lib/indent.c
+++ b/src/lib/indent.c
@@ -426,13 +426,28 @@ indent_text_auto_format(indent_data *id EINA_UNUSED,
    free(utf8);
 
    int saved_space = 0;
+   single_comment_found = EINA_FALSE;
+   multi_comment_found = EINA_FALSE;
    macro_found = EINA_FALSE;
    EINA_LIST_FOREACH(code_lines, l, line)
      {
-        if (!macro_found && line[0] == '#')
+        if (!single_comment_found && !multi_comment_found && !macro_found)
           {
-             macro_found = EINA_TRUE;
-             saved_space = space;
+             if (!strncmp(line, "//", 2))
+               {
+                  single_comment_found = EINA_TRUE;
+                  saved_space = space;
+               }
+             else if (!strncmp(line, "/*", 2))
+               {
+                  multi_comment_found = EINA_TRUE;
+                  saved_space = space;
+               }
+             else if (line[0] == '#')
+               {
+                  macro_found = EINA_TRUE;
+                  saved_space = space;
+               }
           }
         if ((line[0] == '}') && (space > 0))
           space -= TAB_SPACE;
@@ -465,7 +480,17 @@ indent_text_auto_format(indent_data *id EINA_UNUSED,
              bracket_ptr = strstr(bracket_ptr, "}");
           }
 
-        if (macro_found && line[strlen(line) - 1] != '\\')
+        if (single_comment_found)
+          {
+             single_comment_found = EINA_FALSE;
+             space = saved_space;
+          }
+        else if (multi_comment_found && strstr(line, "*/"))
+          {
+             multi_comment_found = EINA_FALSE;
+             space = saved_space;
+          }
+        else if (macro_found && line[strlen(line) - 1] != '\\')
           {
              macro_found = EINA_FALSE;
              space = saved_space;

-- 


Reply via email to