Skip to content

Commit

Permalink
M#0003889 & correction of 5862
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Aug 3, 2021
1 parent 2cce55d commit c753358
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 23 deletions.
7 changes: 7 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -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

Expand Down
28 changes: 13 additions & 15 deletions far/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -293,7 +291,7 @@ void Edit::FastShow(const ShowInfo* Info)
const size_t RealRight = VisualToReal.get(static_cast<int>(EditLength) + LeftPos) - RealLeftPos;

string OutStr;
OutStr.reserve(RealRight);
OutStr.reserve(EditLength);

if (ReconstructedVisualLeftPos < LeftPos)
{
Expand All @@ -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<size_t>(RealLeftPos), OutStrTmp.size());
for(auto i = Begin, End = OutStrTmp.cend(); i != End && static_cast<size_t>(i - Begin) < RealRight; ++i)
const auto Begin = m_Str.cbegin() + std::min(static_cast<size_t>(RealLeftPos), m_Str.usize());
for(auto i = Begin, End = m_Str.cend(); i != End && OutStr.size() < EditLength; ++i)
{
if (*i == L' ')
{
Expand All @@ -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' ');
Expand All @@ -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'';

Expand All @@ -360,26 +358,26 @@ 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);
}
}
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);
}
}
}
}

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'');
}
Expand Down
1 change: 1 addition & 0 deletions far/edit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class Edit: public SimpleScreenObject
public:
using string::string;
int size() const { return static_cast<int>(string::size()); }
auto usize() const { return string::size(); }
};
edit_string m_Str;

Expand Down
15 changes: 8 additions & 7 deletions far/execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5866
5867

0 comments on commit c753358

Please sign in to comment.