Patch #2980 2010-04-11 08:58

ranras

Patch for a Swap header/source issue
Download
2980-Patch_for_a_Sw.patch (1.2 KB)
Category
Application::Refinement
Status
Accepted
Close date
2011-02-13 11:18
Assigned to
mortenmacfly
Index: sdk/editormanager.cpp
===================================================================
--- sdk/editormanager.cpp    (revision 6202)
+++ sdk/editormanager.cpp    (working copy)
@@ -969,6 +969,14 @@
         if (    ((ftActive == ftHeader) && (ftTested == ftSource))
              || ((ftActive == ftSource) && (ftTested == ftHeader)) )
         {
+            if(candidateFile.GetPath() != activeFile.GetPath()) // Check if we are not in the same Directory
+            {
+                wxArrayString fileArray;
+                wxDir::GetAllFiles(candidateFile.GetPath(wxPATH_GET_VOLUME), &fileArray, candidateFile.GetName() + _T(".*"), wxDIR_FILES | wxDIR_HIDDEN);
+                for (unsigned i = 0; i< fileArray.GetCount(); i++)                          // if in this directory there is already
+                    if(wxFileName(fileArray[i]).GetFullName() == activeFile.GetFullName())  // a headerfile (or sourcefile) for our candidatefile
+                        return false;                                                       // it can't be our candidatefile
+            }
             if (candidateFile.FileExists())
                 return true;
         }
mortenmacfly 2010-08-01 09:49

What exactly is being fixed here? Description is missing.

ranras 2010-08-01 18:55

Actually, this is not a fix, is more a refinement for a possible case, were two files (in different directories) have the same name.

Example: A project file with three files

dir1/file.h dir1/file.cpp dir2/file.h

If you are in dir2/file.h and you want to swap the current behavior of Code::Blocks is to open dir1/file.cpp. With this patch, Code::Blocks will first look if there isn't a file.h in that directory, which is in this case and would then ask the user to create a new file.cpp in dir2

I hope you can understand what i have written.