Repository :
https://github.com/FarGroup/FarManager
On branch : master
Link :
https://github.com/FarGroup/FarManager/commit/9b911e1b915cbafc8a2a87a295251c45d33ca226
>---------------------------------------------------------------
commit 9b911e1b915cbafc8a2a87a295251c45d33ca226
Author: Rohitab Batra <
roh...@rohitab.com>
Date: Wed Oct 1 13:39:49 2025 +1000
gh-1019: Enable saving find all results from modal editors
>---------------------------------------------------------------
9b911e1b915cbafc8a2a87a295251c45d33ca226
far/changelog | 5 +++++
far/editor.cpp | 29 ++++++++++-------------------
far/editor.hpp | 1 -
far/vbuild.m4 | 2 +-
4 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/far/changelog b/far/changelog
index f0989fada..95142287f 100644
--- a/far/changelog
+++ b/far/changelog
@@ -1,3 +1,8 @@
+--------------------------------------------------------------------------------
+rohitab 2025-10-01 13:36:49+10:00 - build 6566
+
+1. gh-1019: Enable saving find all results from modal editors.
+
--------------------------------------------------------------------------------
drkns 2025-10-01 00:35:30+01:00 - build 6565
diff --git a/far/editor.cpp b/far/editor.cpp
index 5ac064b10..27a270b7f 100644
--- a/far/editor.cpp
+++ b/far/editor.cpp
@@ -3413,9 +3413,8 @@ namespace
class find_all_list
{
public:
- find_all_list(const size_t MaxLinesCount, const bool CanSaveFoundItemsToNewEditor)
- : m_CanSaveFoundItemsToNewEditor{ CanSaveFoundItemsToNewEditor }
- , m_LineNumColumnMaxWidth{ radix10_formatted_width(MaxLinesCount) }
+ find_all_list(const size_t MaxLinesCount)
+ : m_LineNumColumnMaxWidth{ radix10_formatted_width(MaxLinesCount) }
{}
void add_item(FindCoord FoundCoords, string_view ItemText)
@@ -3444,10 +3443,7 @@ namespace
m_Menu->SetMenuFlags(VMENU_WRAPMODE | VMENU_SHOWAMPERSAND | VMENU_ENABLEALIGNANNOTATIONS);
m_Menu->SetPosition({ -1, m_MenuY1, 0, m_MenuY2 });
m_Menu->SetTitle(far::vformat(msg(lng::MEditSearchStatistics), m_Menu->size(), m_UniqueLineCount));
- if (m_CanSaveFoundItemsToNewEditor)
- m_Menu->SetBottomTitle(KeysToLocalizedText(KEY_CTRLENTER, KEY_F4, KEY_ALTF4, KEY_F5, KEY_SHIFTF5, KEY_ADD, KEY_CTRLUP, KEY_CTRLDOWN));
- else
- m_Menu->SetBottomTitle(KeysToLocalizedText(KEY_CTRLENTER, KEY_F5, KEY_SHIFTF5, KEY_ADD, KEY_CTRLUP, KEY_CTRLDOWN));
+ m_Menu->SetBottomTitle(KeysToLocalizedText(KEY_CTRLENTER, KEY_F4, KEY_ALTF4, KEY_F5, KEY_SHIFTF5, KEY_ADD, KEY_CTRLUP, KEY_CTRLDOWN));
m_Menu->SetHelp(L"FindAllMenu"sv);
m_Menu->SetId(EditorFindAllListId);
@@ -3497,7 +3493,6 @@ namespace
}
const vmenu2_ptr m_Menu{ VMenu2::create({}, {}) };
- const bool m_CanSaveFoundItemsToNewEditor{};
private:
const short m_LineNumColumnMaxWidth{};
@@ -3526,7 +3521,7 @@ void Editor::DoSearchReplace(const SearchReplaceDisposition Disposition)
bool MatchFound{}, UserBreak{};
std::optional<undo_block> UndoBlock;
string QuotedStr;
- auto FindAllList{ FindAll ? std::optional{ find_all_list{ Lines.size(), CanSaveFoundItemsToNewEditor() } } : std::nullopt };
+ auto FindAllList{ FindAll ? std::optional{ find_all_list{ Lines.size() } } : std::nullopt };
{
HideCursor();
@@ -3926,7 +3921,7 @@ void Editor::DoSearchReplace(const SearchReplaceDisposition Disposition)
break;
case KEY_F4:
- if (FindAllList->m_CanSaveFoundItemsToNewEditor && !FindAllList->m_Menu->ListBox().empty())
+ if (!FindAllList->m_Menu->ListBox().empty())
{
SaveToNewEditor = save_to_new_editor::all;
FindAllList->m_Menu->Close();
@@ -3934,7 +3929,7 @@ void Editor::DoSearchReplace(const SearchReplaceDisposition Disposition)
break;
case KEY_ALTF4: case KEY_RALTF4:
- if (FindAllList->m_CanSaveFoundItemsToNewEditor && FindAllList->m_Menu->ListBox().HasVisible())
+ if (FindAllList->m_Menu->ListBox().HasVisible())
{
SaveToNewEditor = save_to_new_editor::matching_filter;
FindAllList->m_Menu->Close();
@@ -3988,13 +3983,6 @@ void Editor::DoSearchReplace(const SearchReplaceDisposition Disposition)
{ lng::MOk });
}
-bool Editor::CanSaveFoundItemsToNewEditor() const
-{
- const auto HostFileEditor = GetHostFileEditor();
- if (!HostFileEditor) return false;
- return HostFileEditor->GetCanLoseFocus();
-}
-
void Editor::SelectFoundPattern(FindCoord coord)
{
GoToLine(coord.Line);
@@ -4016,8 +4004,11 @@ void Editor::SelectFoundPattern(FindCoord coord)
void Editor::SaveFoundItemsToNewEditor(const VMenu& ListBox, const bool MatchingFilter, intptr_t const ExitCode)
{
+ const auto HostFileEditor = GetHostFileEditor();
+ const auto EditorFlags{
+ FFILEEDIT_CANNEWFILE | FFILEEDIT_EPHEMERAL | (HostFileEditor && HostFileEditor->GetCanLoseFocus() ? FFILEEDIT_ENABLEF6 : 0) };
const auto ShellEditor{
- FileEditor::create(GetSearchAllFileName(), GetCodePage(), FFILEEDIT_CANNEWFILE | FFILEEDIT_ENABLEF6 | FFILEEDIT_EPHEMERAL) };
+ FileEditor::create(GetSearchAllFileName(), GetCodePage(), EditorFlags) };
auto& NewEditor{ *ShellEditor->GetEditor() };
const auto FilterFlags{ LIF_HIDDEN | (MatchingFilter ? LIF_FILTERED : 0) };
diff --git a/far/editor.hpp b/far/editor.hpp
index b849ec2b7..314c5e976 100644
--- a/far/editor.hpp
+++ b/far/editor.hpp
@@ -287,7 +287,6 @@ private:
void DoSearchReplace(SearchReplaceDisposition Disposition);
int CalculateSearchStartPosition(bool Continue, bool Backward, bool Regex) const;
int CalculateSearchNextPositionInTheLine(bool Backward, bool Regex) const;
- bool CanSaveFoundItemsToNewEditor() const;
void SelectFoundPattern(FindCoord coord);
void SaveFoundItemsToNewEditor(const VMenu& ListBox, bool MatchingFilter, intptr_t ExitCode);
string GetSearchAllFileName() const;
diff --git a/far/vbuild.m4 b/far/vbuild.m4
index 983fc1e13..24d302ea4 100644
--- a/far/vbuild.m4
+++ b/far/vbuild.m4
@@ -1 +1 @@
-6565
+6566