[PATCH 5/9] StringList.trim_left() support logical tab width

"Jarret \"Jax\" Renker via Docutils-develop" <[email protected]>
Newsgroups gmane.text.docutils.devel
Message-ID <FwSJpeWyD2vV1XzR-kAvfM4wBCGvnBrBseud5DB_IoCNjmVmzsJZMh8ppBh89sToEl0vOA-E1HkOgHVs1cF92Z0oz2pZ9DaQzScZDUBTfUg=@proton.me>
Support logical width for tab characters in the trim_left() function.
---
 docutils/docutils/statemachine.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/docutils/docutils/statemachine.py b/docutils/docutils/statemachine.py
index 167cb7744..4b482c57e 100644
--- a/docutils/docutils/statemachine.py
+++ b/docutils/docutils/statemachine.py
@@ -1324,13 +1324,16 @@ class StringList(ViewList):
 
     """A `ViewList` with string-specific methods."""
 
-    def trim_left(self, length, start=0, end=sys.maxsize):
+    def trim_left(self, length, start=0, end=sys.maxsize, tab_width=8):
         """
-        Trim `length` characters off the beginning of each item, in-place,
-        from index `start` to `end`.  No whitespace-checking is done on the
-        trimmed text.  Does not affect slice parent.
+        Trim `length` logical characters off the beginning of each item,
+        in-place, from index `start` to `end`.  No whitespace-checking is done
+        on the trimmed text.  Does not affect slice parent.
+
+        A tab counts (depending on the column) for up to `tab_width` characters.
+        See `logical_rslice()` for details.
         """
-        self.data[start:end] = [line[length:]
+        self.data[start:end] = [logical_rslice(line, length, tab_width)
                                 for line in self.data[start:end]]
 
     def get_text_block(self, start, flush_left=False):
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.