Skip to content

Commit

Permalink
gh-561: Tab macro %d was not trimmed to ‘Max tab width’.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximus5 committed Mar 1, 2016
1 parent 263453a commit 9f3ecb0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/ConEmu/TabBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,7 @@ int CTabBarClass::PrepareTab(CTab& pTab, CVirtualConsole *apVCon)
if (*pszFmt == _T('%'))
{
pszFmt++;
bool bDynamic = false; // Allowed to trim this part
LPCTSTR pszText = NULL;
switch (*pszFmt)
{
Expand Down Expand Up @@ -1625,6 +1626,7 @@ int CTabBarClass::PrepareTab(CTab& pTab, CVirtualConsole *apVCon)
{
// CTabBarClass::Update will be triggered from CRealConsole::StoreCurWorkDir
// https://conemu.github.io/en/ShellWorkDir.html
bDynamic = true;
pszText = pRCon ? pRCon->GetConsoleCurDir(szArg) : NULL;
if (pszText && (*pszFmt == _T('f') || *pszFmt == _T('F')))
{
Expand All @@ -1651,6 +1653,16 @@ int CTabBarClass::PrepareTab(CTab& pTab, CVirtualConsole *apVCon)
{
if ((*(pszDst-1) == L' ') && (*pszText == L' '))
pszText = SkipNonPrintable(pszText);
TCHAR* pszPartEnd = pszEnd; CEStr lsTrimmed;
if (bDynamic && (nMaxLen > 1) && (wcslen(pszText) > nMaxLen))
{
if (lsTrimmed.Set(pszText))
{
lsTrimmed.ms_Val[nMaxLen-1] = L'\x2026' /*"…"*/;
lsTrimmed.ms_Val[nMaxLen] = 0;
pszText = lsTrimmed.ms_Val;
}
}
while (*pszText && pszDst < pszEnd)
{
*(pszDst++) = *(pszText++);
Expand Down

0 comments on commit 9f3ecb0

Please sign in to comment.