diff --git a/src/Frontend/MainFrame.cpp b/src/Frontend/MainFrame.cpp index fe8ed57c..0118b585 100644 --- a/src/Frontend/MainFrame.cpp +++ b/src/Frontend/MainFrame.cpp @@ -5231,8 +5231,40 @@ void MainFrame::GetNotebookTabSelectedFileNames(std::vector& fileNa void MainFrame::ReloadFile(OpenFile* file) { - file->edit->LoadFile(file->file->fileName.GetFullPath()); + + CodeEdit& editor = *file->edit; + int oldScrollPos = editor.GetScrollPos(wxVSCROLL); + + //Disable modified events so OnCodeEditModified is not called + editor.SetModEventMask(0); + + editor.LoadFile(file->file->fileName.GetFullPath()); file->timeStamp = GetFileModifiedTime(file->file->fileName.GetFullPath()); + + editor.SetModEventMask(wxSCI_MODEVENTMASKALL); + + int newLineCount = editor.GetLineCount(); + + std::vector& breakpoints = file->file->breakpoints; + + //Erase breakpoints past the end of the file and re-add the markers for the rest + for (std::vector::iterator it = breakpoints.begin(); it != breakpoints.end() ;) + { + if (*it >= newLineCount) + { + it = breakpoints.erase(it); + } + else + { + UpdateFileBreakpoint(file, *it, true); + it++; + } + } + + m_breakpointsWindow->UpdateBreakpoints(file->file); + + //Scroll the editor back to the same line we were before the reload + editor.ScrollToLine(oldScrollPos < newLineCount ? oldScrollPos : newLineCount); } void MainFrame::FindInFiles(const wxString& text, const wxArrayString& fileNames, bool matchCase, bool matchWholeWord, const wxString& baseDirectory)