[geany/geany] f90bdc: Only set Find in Files directory once per-document

Nick Treleaven git-noreply at xxxxx
Thu Jul 26 15:13:34 UTC 2012


Branch:      refs/heads/master
Author:      Nick Treleaven <nick.treleaven at btinternet.com>
Committer:   Nick Treleaven <nick.treleaven at btinternet.com>
Date:        Thu, 26 Jul 2012 15:13:34
Commit:      f90bdc5957a827ce044fed6d0a7cd286a7301014
             https://github.com/geany/geany/commit/f90bdc5957a827ce044fed6d0a7cd286a7301014

Log Message:
-----------
Only set Find in Files directory once per-document

Use the current document's directory unless the directory field has
already been edited and the current document has not changed.
Otherwise, prepend the current document's directory to the drop-down
history in case it is wanted.

This is useful to avoid losing the edited directory when it is less
likely the user wants to use the current document's directory.


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

Modified: doc/geany.html
12 files changed, 9 insertions(+), 3 deletions(-)
===================================================================
@@ -1704,6 +1704,8 @@ <h2 class="subtitle" id="a-fast-light-gtk-ide">A fast, light, GTK+ IDE</h2>
 must be correctly set in Preferences to the path of the system's Grep
 utility. GNU Grep is recommended (see note below).</p>
 <img alt="./images/find_in_files_dialog.png" src="./images/find_in_files_dialog.png" />
+<p>The <em>Search</em> field is initially set to the current word in the editor
+(depending on <a class="reference internal" href="#search">Search</a> preferences).</p>
 <p>The <em>Files</em> setting allows to choose which files are included in the
 search, depending on the mode:</p>
 <dl class="docutils">
@@ -1719,6 +1721,10 @@ <h2 class="subtitle" id="a-fast-light-gtk-ide">A fast, light, GTK+ IDE</h2>
 use: <tt class="docutils literal">*.c *.h</tt>.
 Note that an empty pattern list searches in all files rather
 than none.</p>
+<p>The <em>Directory</em> field is initially set to the current document's directory,
+unless this field has already been edited and the current document has
+not changed. Otherwise, the current document's directory is prepended to
+the drop-down history. This can be disabled - see <a class="reference internal" href="#search">Search</a> preferences.</p>
 <p>The <em>Encoding</em> field can be used to define the encoding of the files
 to be searched. The entered search text is converted to the chosen encoding
 and the search results are converted back to UTF-8.</p>
@@ -2218,9 +2224,9 @@ <h2 class="subtitle" id="a-fast-light-gtk-ide">A fast, light, GTK+ IDE</h2>
 there is no selection. When this option is disabled, the search term last used in the
 appropriate Find dialog is used.</dd>
 <dt>Use the current file's directory for Find in Files</dt>
-<dd>When opening the <a class="reference internal" href="#find-in-files">Find in Files</a> dialog, set the directory to search to the directory of the current
+<dd>When opening the Find in Files dialog, set the directory to search to the directory of the current
 active file. When this option is disabled, the directory of the last use of the Find in Files
-dialog is used.</dd>
+dialog is used. See <a class="reference internal" href="#find-in-files">Find in Files</a> for details.</dd>
 </dl>
 </div>
 <div class="section" id="projects">
@@ -6797,7 +6803,7 @@ <h2 class="subtitle" id="a-fast-light-gtk-ide">A fast, light, GTK+ IDE</h2>
 <div class="footer">
 <hr class="footer" />
 <a class="reference external" href="geany.txt">View document source</a>.
-Generated on: 2012-07-26 14:29 UTC.
+Generated on: 2012-07-26 14:56 UTC.
 Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
 
 </div>


Modified: doc/geany.txt
12 files changed, 10 insertions(+), 2 deletions(-)
===================================================================
@@ -1277,6 +1277,9 @@ utility. GNU Grep is recommended (see note below).
 
 .. image:: ./images/find_in_files_dialog.png
 
+The *Search* field is initially set to the current word in the editor
+(depending on `Search`_ preferences).
+
 The *Files* setting allows to choose which files are included in the
 search, depending on the mode:
 
@@ -1293,6 +1296,11 @@ use: ``*.c *.h``.
 Note that an empty pattern list searches in all files rather
 than none.
 
+The *Directory* field is initially set to the current document's directory,
+unless this field has already been edited and the current document has
+not changed. Otherwise, the current document's directory is prepended to
+the drop-down history. This can be disabled - see `Search`_ preferences.
+
 The *Encoding* field can be used to define the encoding of the files
 to be searched. The entered search text is converted to the chosen encoding
 and the search results are converted back to UTF-8.
@@ -1829,9 +1837,9 @@ Use the current word under the cursor for Find dialogs
     appropriate Find dialog is used.
 
 Use the current file's directory for Find in Files
-    When opening the `Find in Files`_ dialog, set the directory to search to the directory of the current
+    When opening the Find in Files dialog, set the directory to search to the directory of the current
     active file. When this option is disabled, the directory of the last use of the Find in Files
-    dialog is used.
+    dialog is used. See `Find in Files`_ for details.
 
 Projects
 ````````


Modified: src/search.c
21 files changed, 18 insertions(+), 3 deletions(-)
===================================================================
@@ -1073,12 +1073,27 @@ void search_show_find_in_files_dialog(const gchar *dir)
 		cur_dir = g_strdup(dir);	/* custom directory argument passed */
 	else
 	{
-		gboolean entry_empty = ! NZV(gtk_entry_get_text(GTK_ENTRY(entry)));
-
-		if (search_prefs.use_current_file_dir || entry_empty)
+		if (search_prefs.use_current_file_dir)
 		{
+			static gchar *last_cur_dir = NULL;
+			static GeanyDocument *last_doc = NULL;
+
+			/* Only set the directory entry once for the current document */
 			cur_dir = utils_get_current_file_dir_utf8();
+			if (doc == last_doc && cur_dir && utils_str_equal(cur_dir, last_cur_dir))
+			{
+				/* in case the user now wants the current directory, add it to history */
+				ui_combo_box_add_to_history(
+					GTK_COMBO_BOX_ENTRY(fif_dlg.dir_combo), cur_dir, 0);
+				SETPTR(cur_dir, NULL);
+			}
+			else
+				SETPTR(last_cur_dir, g_strdup(cur_dir));
 
+			last_doc = doc;
+		}
+		if (!cur_dir && ! NZV(gtk_entry_get_text(GTK_ENTRY(entry))))
+		{
 			/* use default_open_path if no directory could be determined
 			 * (e.g. when no files are open) */
 			if (!cur_dir)


@@ 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