jaehyun pushed a commit to branch master.

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

commit f2d889dbf7b61cd6a09151aca7c28c13f929dbe4
Author: Jaehyun Cho <jae_hyun....@samsung.com>
Date:   Wed Feb 17 16:54:32 2016 +0900

    indent: Fix not to insert a new line between '{' and block name
    
    <Test Case>
    1. Copy "group { "main";" in basic.edc.
    2. Paste
    
    <Test Result>
    Previously, a new line is inserted between "group {" and ""main";".
    Now, the copied text is pasted.
---
 src/lib/indent.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/src/lib/indent.c b/src/lib/indent.c
index 35043c6..3a6a736 100644
--- a/src/lib/indent.c
+++ b/src/lib/indent.c
@@ -256,17 +256,48 @@ indent_text_auto_format(indent_data *id EINA_UNUSED,
    Eina_List *code_lines = NULL;
    Eina_Strbuf *buf = eina_strbuf_new();
 
+   Eina_Bool keep_lexem_start_pos = EINA_FALSE;
+
    int tb_cur_pos = 0;
 
    while (utf8_ptr < utf8_end)
      {
         if (*utf8_ptr != ' ' && *utf8_ptr != '\t' &&  *utf8_ptr != '\n' )
           {
-             utf8_lexem = utf8_ptr;
+             //Renew the start position of lexeme.
+             if (!keep_lexem_start_pos) utf8_lexem = utf8_ptr;
+
              while (utf8_ptr < utf8_end)
                {
                   if (*utf8_ptr == '{' || *utf8_ptr == '}' || *utf8_ptr == ';')
                     {
+                       if (*utf8_ptr == '{')
+                         {
+                            char *bracket_right_ptr = utf8_ptr + 1;
+                            while (bracket_right_ptr < utf8_end)
+                              {
+                                 if (*bracket_right_ptr != ' ' &&
+                                     *bracket_right_ptr != '\t')
+                                   break;
+                                 bracket_right_ptr++;
+                              }
+                            if (bracket_right_ptr < utf8_end)
+                              {
+                                 /* To preserve code line until block name,
+                                    keep start position of lexeme and append
+                                    code line until ';'. */
+                                 if (*bracket_right_ptr == '\"' ||
+                                     (bracket_right_ptr + 4 < utf8_end &&
+                                      !strncmp(bracket_right_ptr, "name:", 5)))
+                                   {
+                                      keep_lexem_start_pos = EINA_TRUE;
+                                      break;
+                                   }
+                              }
+                         }
+                       else if (*utf8_ptr == ';')
+                         keep_lexem_start_pos = EINA_FALSE;
+
                        if (utf8_ptr + 1 == utf8_end)
                          code_lines = eina_list_append(code_lines,
                                          eina_stringshare_add(utf8_lexem));
@@ -373,6 +404,8 @@ indent_insert_apply(indent_data *id, Evas_Object *entry, 
const char *insert,
             indent_insert_br_case(id, entry);
             return 1;
           }
+        else if (!strcmp(insert, QUOT))
+          return 0;
         else
           return indent_text_auto_format(id, entry, insert);
      }

-- 


Reply via email to