ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=3999fb67fdae1b2acca7c892f6d4f9535bec9636

commit 3999fb67fdae1b2acca7c892f6d4f9535bec9636
Author: Andy Williams <a...@andywilliams.me>
Date:   Sat Aug 29 14:11:40 2015 +0100

    [elm_code] don't strip whitespace on current line
    
    When saving if any widget has a cursor on the line
    we shouldn't strip the trailing whitespace
---
 elm_code/src/lib/elm_code_file.c |  3 ++-
 elm_code/src/lib/elm_code_line.c | 21 +++++++++++++++++++++
 elm_code/src/lib/elm_code_line.h |  2 ++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/elm_code/src/lib/elm_code_file.c b/elm_code/src/lib/elm_code_file.c
index 387e249..07ff643 100644
--- a/elm_code/src/lib/elm_code_file.c
+++ b/elm_code/src/lib/elm_code_file.c
@@ -178,7 +178,8 @@ EAPI void elm_code_file_save(Elm_Code_File *file)
 
    EINA_LIST_FOREACH(file->lines, item, line_item)
      {
-        elm_code_line_text_trailing_whitespace_strip(line_item);
+        if (!elm_code_line_contains_widget_cursor(line_item))
+          elm_code_line_text_trailing_whitespace_strip(line_item);
         content = elm_code_line_text_get(line_item, &length);
 
         fwrite(content, sizeof(char), length, out);
diff --git a/elm_code/src/lib/elm_code_line.c b/elm_code/src/lib/elm_code_line.c
index e0de0d5..ae921f7 100644
--- a/elm_code/src/lib/elm_code_line.c
+++ b/elm_code/src/lib/elm_code_line.c
@@ -106,3 +106,24 @@ EAPI void elm_code_line_status_clear(Elm_Code_Line *line)
      }
 }
 
+EAPI Eina_Bool
+elm_code_line_contains_widget_cursor(Elm_Code_Line *line)
+{
+   Elm_Code *code = line->file->parent;
+   Eina_List *item;
+   Eo *widget;
+   unsigned int col, number;
+
+   if (!code)
+     return EINA_FALSE;
+
+   EINA_LIST_FOREACH(code->widgets, item, widget)
+     {
+        elm_code_widget_cursor_position_get(widget, &col, &number);
+
+        if (number == line->number)
+          return EINA_TRUE;
+     }
+
+   return EINA_FALSE;
+}
diff --git a/elm_code/src/lib/elm_code_line.h b/elm_code/src/lib/elm_code_line.h
index 6a0f767..822cbea 100644
--- a/elm_code/src/lib/elm_code_line.h
+++ b/elm_code/src/lib/elm_code_line.h
@@ -69,6 +69,8 @@ EAPI void elm_code_line_token_add(Elm_Code_Line *line, int 
start, int end, int l
 
 EAPI void elm_code_line_tokens_clear(Elm_Code_Line *line);
 
+EAPI Eina_Bool elm_code_line_contains_widget_cursor(Elm_Code_Line *line);
+
 /**
  * @}
  */

-- 


Reply via email to