From fbd6af9919475622d999d8ed418b731bed39cf4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Sat, 9 Jun 2007 12:11:18 +0000 Subject: [PATCH] =?UTF-8?q?Apply=20from=20Fran=C3=A7ois=20Cami=20and=20Gui?= =?UTF-8?q?llaume=20Duviol=20to=20improve=20replacement=20of=20tabs=20by?= =?UTF-8?q?=20spaces=20(thank=20you).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1603 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 7 +++++++ THANKS | 1 + src/document.c | 17 ++++++++++------- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index f3653c3f..8be8313d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-06-09 Enrico Tröger + + * THANKS, src/document.c: + Apply from François Cami and Guillaume Duviol to improve replacement + of tabs by spaces (thank you). + + 2007-06-08 Frank Lanitz * THANKS, src/about.c: Added new translator Adrovane Marques Kade. diff --git a/THANKS b/THANKS index ccfdfcc3..63b8bfdb 100644 --- a/THANKS +++ b/THANKS @@ -30,6 +30,7 @@ Anh Phạm - various patches Guillaume Hoffmann - Haskell filetype patch Peter Strand - Haskell CTags patch Dave Moore - code navigation patch +François Cami , Guillaume Duviol - tab replacement patch Translators: ---------------------------------- diff --git a/src/document.c b/src/document.c index 47ef83dd..aac3790e 100644 --- a/src/document.c +++ b/src/document.c @@ -1800,7 +1800,7 @@ void document_print(gint idx) void document_replace_tabs(gint idx) { - gint search_pos; + gint search_pos, pos_in_line, current_tab_true_length; gint tab_len; gchar *tab_str; struct TextToFind ttf; @@ -1811,22 +1811,25 @@ void document_replace_tabs(gint idx) tab_len = sci_get_tab_width(doc_list[idx].sci); ttf.chrg.cpMin = 0; ttf.chrg.cpMax = sci_get_length(doc_list[idx].sci); - ttf.lpstrText = (gchar*)"\t"; - tab_str = g_strnfill(tab_len, ' '); + ttf.lpstrText = (gchar*) "\t"; while (TRUE) { search_pos = sci_find_text(doc_list[idx].sci, SCFIND_MATCHCASE, &ttf); - if (search_pos == -1) break; + if (search_pos == -1) + break; + pos_in_line = sci_get_col_from_position(doc_list[idx].sci,search_pos); + current_tab_true_length = tab_len - (pos_in_line % tab_len); + tab_str = g_strnfill(current_tab_true_length, ' '); sci_target_start(doc_list[idx].sci, search_pos); sci_target_end(doc_list[idx].sci, search_pos + 1); sci_target_replace(doc_list[idx].sci, tab_str, FALSE); - ttf.chrg.cpMin = search_pos + tab_len - 1; // next search starts after replacement - ttf.chrg.cpMax += tab_len - 1; // update end of range now text has changed + ttf.chrg.cpMin = search_pos + current_tab_true_length - 1; // next search starts after replacement + ttf.chrg.cpMax += current_tab_true_length - 1; // update end of range now text has changed + g_free(tab_str); } sci_end_undo_action(doc_list[idx].sci); - g_free(tab_str); }