Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan McGovern <alan.mcgovern@gmail.com>2011-09-28 14:11:45 +0400
committerAlan McGovern <alan.mcgovern@gmail.com>2011-09-28 14:17:08 +0400
commitbb7dac9e53c1c248c607b54a6dae14965f0d5b48 (patch)
tree3fa58da633a8711bfd0343ebc35e4cce751bff37 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles
parent7694c3e32d6c974039d4146871b6176d2a6fad78 (diff)
[Ide] Respect 'Include Binary Files' for Project and Solution search scopes
Fixes #1014 so that searching in Project and Solution scopes does not always include binary files.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindInFilesDialog.cs41
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/Scope.cs31
2 files changed, 39 insertions, 33 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindInFilesDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindInFilesDialog.cs
index 8a09727081..8f4e4efaa4 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindInFilesDialog.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindInFilesDialog.cs
@@ -442,45 +442,56 @@ namespace MonoDevelop.Ide.FindInFiles
Scope GetScope ()
{
+
+ var properties = PropertyService.Get ("MonoDevelop.FindReplaceDialogs.SearchOptions", new Properties ());
+ Scope scope = null;
+
switch (comboboxScope.Active) {
case ScopeCurrentDocument:
- return new DocumentScope ();
+ scope = new DocumentScope ();
+ break;
case ScopeSelection:
- return new SelectionScope ();
+ scope = new SelectionScope ();
+ break;
case ScopeWholeSolution:
if (!IdeApp.Workspace.IsOpen) {
MessageService.ShowError (GettextCatalog.GetString ("Currently there is no open solution."));
return null;
}
- return new WholeSolutionScope ();
+ scope = new WholeSolutionScope ();
+ break;
case ScopeCurrentProject:
MonoDevelop.Projects.Project currentSelectedProject = IdeApp.ProjectOperations.CurrentSelectedProject;
if (currentSelectedProject != null)
- return new WholeProjectScope (currentSelectedProject);
+ scope = new WholeProjectScope (currentSelectedProject);
if (IdeApp.Workspace.IsOpen && IdeApp.ProjectOperations.CurrentSelectedSolution != null) {
AlertButton alertButton = MessageService.AskQuestion (GettextCatalog.GetString ("Currently there is no project selected. Search in the solution instead ?"), AlertButton.Yes, AlertButton.No);
if (alertButton == AlertButton.Yes)
- return new WholeSolutionScope ();
+ scope = new WholeSolutionScope ();
} else {
MessageService.ShowError (GettextCatalog.GetString ("Currently there is no open solution."));
- }
- return null;
+ return null;
+ }
+ break;
case ScopeAllOpenFiles:
- return new AllOpenFilesScope ();
+ scope = new AllOpenFilesScope ();
+ break;
case ScopeDirectories:
if (!System.IO.Directory.Exists (comboboxentryPath.Entry.Text)) {
MessageService.ShowError (string.Format (GettextCatalog.GetString ("Directory not found: {0}"), comboboxentryPath.Entry.Text));
return null;
}
- var directoryScope = new DirectoryScope (comboboxentryPath.Entry.Text, checkbuttonRecursively.Active);
-
- var properties = PropertyService.Get ("MonoDevelop.FindReplaceDialogs.SearchOptions", new Properties ());
- directoryScope.IncludeBinaryFiles = properties.Get ("IncludeBinaryFiles", false);
- directoryScope.IncludeHiddenFiles = properties.Get ("IncludeHiddenFiles", false);
- return directoryScope;
+ scope = new DirectoryScope (comboboxentryPath.Entry.Text, checkbuttonRecursively.Active) {
+ IncludeHiddenFiles = properties.Get ("IncludeHiddenFiles", false)
+ };
+ break;
+ default:
+ throw new ApplicationException ("Unknown scope:" + comboboxScope.Active);
}
- throw new ApplicationException ("Unknown scope:" + comboboxScope.Active);
+
+ scope.IncludeBinaryFiles = properties.Get ("IncludeBinaryFiles", false);
+ return scope;
}
FilterOptions GetFilterOptions ()
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/Scope.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/Scope.cs
index a6b8ca4b75..32c66615f8 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/Scope.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/Scope.cs
@@ -37,6 +37,11 @@ namespace MonoDevelop.Ide.FindInFiles
{
public abstract class Scope
{
+ public bool IncludeBinaryFiles {
+ get;
+ set;
+ }
+
public abstract int GetTotalWork (FilterOptions filterOptions);
public abstract IEnumerable<FileProvider> GetFiles (IProgressMonitor monitor, FilterOptions filterOptions);
public abstract string GetDescription (FilterOptions filterOptions, string pattern, string replacePattern);
@@ -103,6 +108,8 @@ namespace MonoDevelop.Ide.FindInFiles
foreach (Project project in IdeApp.Workspace.GetAllProjects ()) {
monitor.Log.WriteLine (GettextCatalog.GetString ("Looking in project '{0}'", project.Name));
foreach (ProjectFile file in project.Files.Where (f => filterOptions.NameMatches (f.Name) && File.Exists (f.Name))) {
+ if (!IncludeBinaryFiles && DesktopService.MimeTypeIsBinary (DesktopService.GetMimeTypeForUri (file.Name)))
+ continue;
yield return new FileProvider (file.Name, project);
}
}
@@ -138,9 +145,12 @@ namespace MonoDevelop.Ide.FindInFiles
{
if (IdeApp.Workspace.IsOpen) {
monitor.Log.WriteLine (GettextCatalog.GetString ("Looking in project '{0}'", project.Name));
- return project.Files.Where (f => filterOptions.NameMatches (f.Name) && File.Exists (f.Name)).Select (f => new FileProvider (f.Name, project));
+ foreach (ProjectFile file in project.Files.Where (f => filterOptions.NameMatches (f.Name) && File.Exists (f.Name))) {
+ if (!IncludeBinaryFiles && DesktopService.MimeTypeIsBinary (DesktopService.GetMimeTypeForUri (file.Name)))
+ continue;
+ yield return new FileProvider (file.Name, project);
+ }
}
- return Enumerable.Empty<FileProvider> ();
}
public override string GetDescription (FilterOptions filterOptions, string pattern, string replacePattern)
@@ -182,11 +192,6 @@ namespace MonoDevelop.Ide.FindInFiles
readonly string path;
readonly bool recurse;
- public bool IncludeBinaryFiles {
- get;
- set;
- }
-
public bool IncludeHiddenFiles {
get;
set;
@@ -203,16 +208,6 @@ namespace MonoDevelop.Ide.FindInFiles
this.recurse = recurse;
}
- static bool MimeTypeIsBinary (string mimeType)
- {
- if (string.IsNullOrEmpty (mimeType))
- return false;
- return !(mimeType.StartsWith ("text/") ||
- mimeType == "image/x-xbitmap" ||
- mimeType == "image/x-xpixmap" ||
- mimeType.EndsWith ("+xml"));
- }
-
IEnumerable<string> GetFileNames (IProgressMonitor monitor, FilterOptions filterOptions)
{
if (monitor != null)
@@ -229,7 +224,7 @@ namespace MonoDevelop.Ide.FindInFiles
foreach (string fileName in files) {
if (fileName.StartsWith (".") && !IncludeHiddenFiles)
continue;
- if (!IncludeBinaryFiles && MimeTypeIsBinary (DesktopService.GetMimeTypeForUri (fileName)))
+ if (!IncludeBinaryFiles && DesktopService.MimeTypeIsBinary (DesktopService.GetMimeTypeForUri (fileName)))
continue;
yield return fileName;
}