From c7533589e376a0a0a29f037e47338bbf1d4ce5f3 Mon Sep 17 00:00:00 2001 From: Alex Alabuzhev Date: Tue, 3 Aug 2021 17:50:33 +0100 Subject: [PATCH] M#0003889 & correction of 5862 --- far/changelog | 7 +++++++ far/edit.cpp | 28 +++++++++++++--------------- far/edit.hpp | 1 + far/execute.cpp | 15 ++++++++------- far/vbuild.m4 | 2 +- 5 files changed, 30 insertions(+), 23 deletions(-) diff --git a/far/changelog b/far/changelog index f6c5d008c8..8ee9ecbba8 100644 --- a/far/changelog +++ b/far/changelog @@ -1,3 +1,10 @@ +-------------------------------------------------------------------------------- +drkns 03.08.2021 17:48:48 +0100 - build 5867 + +1. 0003889: Editor white space wasn't rendered in certain cases. + +2. Correction of 5862. + -------------------------------------------------------------------------------- drkns 03.08.2021 02:04:01 +0100 - build 5866 diff --git a/far/edit.cpp b/far/edit.cpp index 976fe6227f..860227827d 100644 --- a/far/edit.cpp +++ b/far/edit.cpp @@ -283,8 +283,6 @@ void Edit::FastShow(const ShowInfo* Info) SetLineCursorPos(TabCurPos); - string_view OutStrTmp = m_Str; - auto RealLeftPos = VisualToReal.get(LeftPos); const auto ReconstructedVisualLeftPos = RealToVisual.get(RealLeftPos); @@ -293,7 +291,7 @@ void Edit::FastShow(const ShowInfo* Info) const size_t RealRight = VisualToReal.get(static_cast(EditLength) + LeftPos) - RealLeftPos; string OutStr; - OutStr.reserve(RealRight); + OutStr.reserve(EditLength); if (ReconstructedVisualLeftPos < LeftPos) { @@ -312,14 +310,14 @@ void Edit::FastShow(const ShowInfo* Info) } { - auto TrailingSpaces = OutStrTmp.cend(); - if (m_Flags.Check(FEDITLINE_PARENT_SINGLELINE|FEDITLINE_PARENT_MULTILINE) && Mask.empty() && !OutStrTmp.empty()) + auto TrailingSpaces = m_Str.cend(); + if (m_Flags.Check(FEDITLINE_PARENT_SINGLELINE|FEDITLINE_PARENT_MULTILINE) && Mask.empty() && !m_Str.empty()) { - TrailingSpaces = std::find_if_not(OutStrTmp.crbegin(), OutStrTmp.crend(), [](wchar_t i) { return std::iswblank(i);}).base(); + TrailingSpaces = std::find_if_not(m_Str.crbegin(), m_Str.crend(), [](wchar_t i) { return std::iswblank(i);}).base(); } - const auto Begin = OutStrTmp.cbegin() + std::min(static_cast(RealLeftPos), OutStrTmp.size()); - for(auto i = Begin, End = OutStrTmp.cend(); i != End && static_cast(i - Begin) < RealRight; ++i) + const auto Begin = m_Str.cbegin() + std::min(static_cast(RealLeftPos), m_Str.usize()); + for(auto i = Begin, End = m_Str.cend(); i != End && OutStr.size() < EditLength; ++i) { if (*i == L' ') { @@ -330,8 +328,8 @@ void Edit::FastShow(const ShowInfo* Info) } else if (*i == L'\t') { - const auto TabStart = RealToVisual.get(i - OutStrTmp.begin()); - const auto TabEnd = RealToVisual.get(i + 1 - OutStrTmp.begin()); + const auto TabStart = RealToVisual.get(i - m_Str.begin()); + const auto TabEnd = RealToVisual.get(i + 1 - m_Str.begin()); OutStr.push_back(((m_Flags.Check(FEDITLINE_SHOWWHITESPACE) && m_Flags.Check(FEDITLINE_EDITORMODE)) || i >= TrailingSpaces)? L'→' : L' '); OutStr.resize(OutStr.size() + TabEnd - TabStart - 1, L' '); @@ -345,7 +343,7 @@ void Edit::FastShow(const ShowInfo* Info) if (m_Flags.Check(FEDITLINE_PASSWORDMODE)) OutStr.assign(OutStr.size(), L'*'); - if (m_Flags.Check(FEDITLINE_SHOWLINEBREAK) && m_Flags.Check(FEDITLINE_EDITORMODE) && (m_Str.size() >= RealLeftPos) && (OutStr.size() < RealRight)) + if (m_Flags.Check(FEDITLINE_SHOWLINEBREAK) && m_Flags.Check(FEDITLINE_EDITORMODE) && (m_Str.size() >= RealLeftPos) && (OutStr.size() < EditLength)) { const auto Cr = L'♪', Lf = L'◙'; @@ -360,7 +358,7 @@ void Edit::FastShow(const ShowInfo* Info) else if (m_Eol == eol::win) { OutStr.push_back(Cr); - if(OutStr.size() < RealRight) + if(OutStr.size() < EditLength) { OutStr.push_back(Lf); } @@ -368,10 +366,10 @@ void Edit::FastShow(const ShowInfo* Info) else if (m_Eol == eol::bad_win) { OutStr.push_back(Cr); - if(OutStr.size() < RealRight) + if(OutStr.size() < EditLength) { OutStr.push_back(Cr); - if(OutStr.size() < RealRight) + if(OutStr.size() < EditLength) { OutStr.push_back(Lf); } @@ -379,7 +377,7 @@ void Edit::FastShow(const ShowInfo* Info) } } - if (m_Flags.Check(FEDITLINE_SHOWWHITESPACE) && m_Flags.Check(FEDITLINE_EDITORMODE) && (m_Str.size() >= RealLeftPos) && (OutStr.size() < RealRight) && GetEditor()->IsLastLine(this)) + if (m_Flags.Check(FEDITLINE_SHOWWHITESPACE) && m_Flags.Check(FEDITLINE_EDITORMODE) && (m_Str.size() >= RealLeftPos) && (OutStr.size() < EditLength) && GetEditor()->IsLastLine(this)) { OutStr.push_back(L'□'); } diff --git a/far/edit.hpp b/far/edit.hpp index d02dfe98cd..f8370787b6 100644 --- a/far/edit.hpp +++ b/far/edit.hpp @@ -243,6 +243,7 @@ class Edit: public SimpleScreenObject public: using string::string; int size() const { return static_cast(string::size()); } + auto usize() const { return string::size(); } }; edit_string m_Str; diff --git a/far/execute.cpp b/far/execute.cpp index 282eb34cbd..47cdb77bbe 100644 --- a/far/execute.cpp +++ b/far/execute.cpp @@ -530,13 +530,14 @@ static bool execute_shell(string const& Command, string const& Parameters, strin // but ShellExecuteEx might still resort to some AI // and turn path\file_without_ext into path\file_without_ext.exe. // To prevent that, we specify the extension explicitly. - auto Extension = name_ext(Command).second; - if (Extension.empty()) - Extension = L"."sv; - - // .data() is fine, the underlying string is in the outer scope and null-terminated. - Info.lpClass = Extension.data(); - Info.fMask |= SEE_MASK_CLASSNAME; + if (auto Extension = name_ext(Command).second; !equal_icase(Extension, L".lnk"sv)) + { + if (Extension.empty()) + Extension = L"."sv; + // .data() is fine, the underlying string is in the outer scope and null-terminated. + Info.lpClass = Extension.data(); + Info.fMask |= SEE_MASK_CLASSNAME; + } } if (!ShellExecuteEx(&Info)) diff --git a/far/vbuild.m4 b/far/vbuild.m4 index 69b0804d31..a328b99f49 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -5866 +5867