[geany/geany] 0c6aed: Make 'Replace Spaces by Tabs' only match leading spaces

Nick Treleaven git-noreply at xxxxx
Thu Jul 26 00:02:20 UTC 2012


Branch:      refs/heads/document-messages
Author:      Nick Treleaven <nick.treleaven at btinternet.com>
Committer:   Nick Treleaven <nick.treleaven at btinternet.com>
Date:        Wed, 21 Dec 2011 17:06:32
Commit:      0c6aed700dd89a7abab7b1b5bfca340e1a2d6c7f
             https://github.com/geany/geany/commit/0c6aed700dd89a7abab7b1b5bfca340e1a2d6c7f

Log Message:
-----------
Make 'Replace Spaces by Tabs' only match leading spaces

Replacing spaces used for alignment with tabs would often break the
alignment as tab stop positions were not checked. It's also not
possible to distinguish between a true space and a single aligning
space, so we should ignore all spaces outside of indentation.


Modified Paths:
--------------
    doc/geany.html
    doc/geany.txt
    src/editor.c

Modified: doc/geany.html
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -4407,7 +4407,7 @@ <h2 class="subtitle" id="a-fast-light-gtk-ide">A fast, light, GTK+ IDE</h2>
 </tr>
 <tr><td>Replace spaces by tabs</td>
 <td> </td>
-<td>Replaces all spaces with tab characters.</td>
+<td>Replaces leading spaces with tab characters.</td>
 </tr>
 <tr><td>Toggle current fold</td>
 <td> </td>


Modified: doc/geany.txt
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -3604,7 +3604,7 @@ Action                               Default shortcut     Description
 ==================================== ==================== ==================================================
 Replace tabs by space                                     Replaces all tabs with the right amount of spaces.
 
-Replace spaces by tabs                                    Replaces all spaces with tab characters.
+Replace spaces by tabs                                    Replaces leading spaces with tab characters.
 
 Toggle current fold                                       Toggles the folding state of the current code block.
 


Modified: src/editor.c
8 files changed, 7 insertions(+), 1 deletions(-)
===================================================================
@@ -4320,7 +4320,13 @@ void editor_replace_spaces(GeanyEditor *editor)
 		search_pos = sci_find_text(editor->sci, SCFIND_MATCHCASE, &ttf);
 		if (search_pos == -1)
 			break;
-
+		/* only replace indentation because otherwise we can mess up alignment */
+		if (search_pos > sci_get_line_indent_position(editor->sci,
+			sci_get_line_from_position(editor->sci, search_pos)))
+		{
+			ttf.chrg.cpMin = search_pos + tab_len;
+			continue;
+		}
 		sci_set_target_start(editor->sci, search_pos);
 		sci_set_target_end(editor->sci, search_pos + tab_len);
 		sci_replace_target(editor->sci, "\t", FALSE);


@@ Diff output truncated at 100000 characters. @@


--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).



More information about the Commits mailing list