Hi Cami,
Thanks a lot, now it's perfect.
Cheers
Amir
FD Cami <francois.cami@free.fr> wrote:
Hi List,
On Fri, 8 Jun 2007 01:20:50 +0200
FD Camiwrote:
> Patch attached & validated against the attached test file and sonata.py
> with tab_len = 8.
The same patch without the obvious memory leak...
Cheers
François Cami & Guillaume Duviol
--- ../geany-0.11/src/document.c 2007-05-21 17:36:37.000000000 +0200
+++ src/document.c 2007-06-08 07:06:17.000000000 +0200
@@ -1785,5 +1785,5 @@
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;
@@ -1797,5 +1797,4 @@
ttf.chrg.cpMax = sci_get_length(doc_list[idx].sci);
ttf.lpstrText = (gchar*)"\t";
- tab_str = g_strnfill(tab_len, ' ');
while (TRUE)
@@ -1804,12 +1803,15 @@
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
+ g_free(tab_str);
+ 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
}
sci_end_undo_action(doc_list[idx].sci);
- g_free(tab_str);
}
_______________________________________________
Geany mailing list
Geany@uvena.de
http://uvena.de/cgi-bin/mailman/listinfo/geany