OSDN Git Service

Fix issue #998: Cannot resize last column with UI
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sat, 9 Oct 2021 23:54:53 +0000 (08:54 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sat, 9 Oct 2021 23:54:53 +0000 (08:54 +0900)
Externals/crystaledit/editlib/ccrystaltextbuffer.h
Externals/crystaledit/editlib/ccrystaltextview.cpp

index 664ff46..7849cd1 100644 (file)
@@ -314,7 +314,7 @@ public :
     }
     int  GetColumnWidth (int nColumnIndex) const;
     void SetColumnWidth (int nColumnIndex, int nColumnWidth);
-    std::vector<int> GetColumnWidths () const { return m_pSharedTableProps->m_aColumnWidths; }
+    const std::vector<int>& GetColumnWidths () const { return m_pSharedTableProps->m_aColumnWidths; }
     void SetColumnWidths (const std::vector<int>& columnWidths);
     int  GetColumnCount (int nLineIndex) const;
     void SetAllowNewlinesInQuotes (bool bAllowNewlinesInQuotes) { m_bAllowNewlinesInQuotes = bAllowNewlinesInQuotes; }
index 8c00bb9..313c61d 100644 (file)
@@ -88,6 +88,7 @@
 #include "StdAfx.h"
 #include <vector>
 #include <algorithm>
+#include <numeric>
 #include <malloc.h>
 #include <imm.h> /* IME */
 #include "editcmd.h"
@@ -4103,8 +4104,9 @@ RecalcHorzScrollBar (bool bPositionOnly /*= false*/, bool bRedraw /*= true */)
   si.cbSize = sizeof (si);
 
   const int nScreenChars = GetScreenChars();
+  const TextLayoutMode layoutMode = GetTextLayoutMode ();
   
-  if (GetTextLayoutMode () == TEXTLAYOUT_WORDWRAP)
+  if (layoutMode == TEXTLAYOUT_WORDWRAP)
     {
       if (m_nOffsetChar > nScreenChars)
         {
@@ -4119,7 +4121,12 @@ RecalcHorzScrollBar (bool bPositionOnly /*= false*/, bool bRedraw /*= true */)
       return;
     }
 
-  const int nMaxLineLen = GetMaxLineLength (m_nTopLine, GetScreenLines());
+  int nMaxLineLen = GetMaxLineLength (m_nTopLine, GetScreenLines());
+  if (layoutMode == TEXTLAYOUT_TABLE_NOWORDWRAP || layoutMode == TEXTLAYOUT_TABLE_WORDWRAP)
+    {
+      auto widths = m_pTextBuffer->GetColumnWidths ();
+      nMaxLineLen = (std::max)(nMaxLineLen, std::accumulate (widths.begin (), widths.end (), 0));
+    }
 
   if (bPositionOnly)
     {