ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=3b60da0e37c00a34a949b7354bcd333414c01c0b

commit 3b60da0e37c00a34a949b7354bcd333414c01c0b
Author: Andy Williams <[email protected]>
Date:   Sat Feb 17 19:05:14 2018 +0000

    elm_code: Fix line selection with leading tabs
---
 src/lib/elementary/elm_code_widget_selection.c        | 4 +++-
 src/tests/elementary/elm_code_test_widget_selection.c | 7 +++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/lib/elementary/elm_code_widget_selection.c 
b/src/lib/elementary/elm_code_widget_selection.c
index e89c9d45da..de76a4b34e 100644
--- a/src/lib/elementary/elm_code_widget_selection.c
+++ b/src/lib/elementary/elm_code_widget_selection.c
@@ -302,6 +302,7 @@ elm_code_widget_selection_select_line(Evas_Object *widget, 
unsigned int line)
 {
    Elm_Code_Widget_Data *pd;
    Elm_Code_Line *lineobj;
+   unsigned int col;
 
    pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
    lineobj = elm_code_file_line_get(pd->code->file, line);
@@ -310,7 +311,8 @@ elm_code_widget_selection_select_line(Evas_Object *widget, 
unsigned int line)
      return;
 
    elm_code_widget_selection_start(widget, line, 1);
-   elm_code_widget_selection_end(widget, line, lineobj->length);
+   col = elm_code_widget_line_text_column_width_to_position(widget, lineobj, 
lineobj->length);
+   elm_code_widget_selection_end(widget, line, col);
 }
 
 #endif // ELM_CODE_TEST
diff --git a/src/tests/elementary/elm_code_test_widget_selection.c 
b/src/tests/elementary/elm_code_test_widget_selection.c
index 5790c9b24b..e8f1481d9d 100644
--- a/src/tests/elementary/elm_code_test_widget_selection.c
+++ b/src/tests/elementary/elm_code_test_widget_selection.c
@@ -551,6 +551,7 @@ START_TEST (elm_code_test_widget_selection_select_line)
    file = elm_code_file_new(code);
    elm_code_file_line_append(file, "line selection", 14, NULL);
    elm_code_file_line_append(file, "line2", 5, NULL);
+   elm_code_file_line_append(file, "\ttab", 4, NULL);
 
    win = elm_win_add(NULL, "entry", ELM_WIN_BASIC);
    widget = elm_code_widget_add(win, code);
@@ -564,6 +565,12 @@ START_TEST (elm_code_test_widget_selection_select_line)
    selection = elm_code_widget_selection_text_get(widget);
    ck_assert_str_eq("line2", selection);
    free(selection);
+
+   elm_code_widget_selection_select_line(widget, 3);
+   selection = elm_code_widget_selection_text_get(widget);
+   ck_assert_str_eq("\ttab", selection);
+   free(selection);
+
    elm_shutdown();
 }
 END_TEST

-- 


Reply via email to