Method: rich.text.Text.expand_tabs
Calls: 107, Exceptions: 0, Paths: 4Back
Path 1: 103 calls (0.96)
None (103)
None (103)
1def expand_tabs(self, tab_size: Optional[int] = None) -> None:
2 """Converts tabs to spaces.
3
4 Args:
5 tab_size (int, optional): Size of tabs. Defaults to 8.
6
7 """
8 if "\t" not in self.plain:
9 return
10 pos = 0
11 if tab_size is None:
12 tab_size = self.tab_size
13 assert tab_size is not None
14 result = self.blank_copy()
15 append = result.append
16
17 _style = self.style
18 for line in self.split("\n", include_separator=True):
19 parts = line.split("\t", include_separator=True)
20 for part in parts:
21 if part.plain.endswith("\t"):
22 part._text = [part.plain[:-1] + " "]
23 append(part)
24 pos += len(part)
25 spaces = tab_size - ((pos - 1) % tab_size) - 1
26 if spaces:
27 append(" " * spaces, _style)
28 pos += spaces
29 else:
30 append(part)
31 self._text = [result.plain]
32 self._length = len(self.plain)
33 self._spans[:] = result._spans
Path 2: 2 calls (0.02)
None (2)
1def expand_tabs(self, tab_size: Optional[int] = None) -> None:
2 """Converts tabs to spaces.
3
4 Args:
5 tab_size (int, optional): Size of tabs. Defaults to 8.
6
7 """
8 if "\t" not in self.plain:
9 return
10 pos = 0
11 if tab_size is None:
12 tab_size = self.tab_size
13 assert tab_size is not None
14 result = self.blank_copy()
15 append = result.append
16
17 _style = self.style
18 for line in self.split("\n", include_separator=True):
19 parts = line.split("\t", include_separator=True)
20 for part in parts:
21 if part.plain.endswith("\t"):
22 part._text = [part.plain[:-1] + " "]
23 append(part)
24 pos += len(part)
25 spaces = tab_size - ((pos - 1) % tab_size) - 1
26 if spaces:
27 append(" " * spaces, _style)
28 pos += spaces
29 else:
30 append(part)
31 self._text = [result.plain]
32 self._length = len(self.plain)
33 self._spans[:] = result._spans
Path 3: 1 calls (0.01)
8 (1)
1def expand_tabs(self, tab_size: Optional[int] = None) -> None:
2 """Converts tabs to spaces.
3
4 Args:
5 tab_size (int, optional): Size of tabs. Defaults to 8.
6
7 """
8 if "\t" not in self.plain:
9 return
10 pos = 0
11 if tab_size is None:
12 tab_size = self.tab_size
13 assert tab_size is not None
14 result = self.blank_copy()
15 append = result.append
16
17 _style = self.style
18 for line in self.split("\n", include_separator=True):
19 parts = line.split("\t", include_separator=True)
20 for part in parts:
21 if part.plain.endswith("\t"):
22 part._text = [part.plain[:-1] + " "]
23 append(part)
24 pos += len(part)
25 spaces = tab_size - ((pos - 1) % tab_size) - 1
26 if spaces:
27 append(" " * spaces, _style)
28 pos += spaces
29 else:
30 append(part)
31 self._text = [result.plain]
32 self._length = len(self.plain)
33 self._spans[:] = result._spans
Path 4: 1 calls (0.01)
None (1)
1def expand_tabs(self, tab_size: Optional[int] = None) -> None:
2 """Converts tabs to spaces.
3
4 Args:
5 tab_size (int, optional): Size of tabs. Defaults to 8.
6
7 """
8 if "\t" not in self.plain:
9 return
10 pos = 0
11 if tab_size is None:
12 tab_size = self.tab_size
13 assert tab_size is not None
14 result = self.blank_copy()
15 append = result.append
16
17 _style = self.style
18 for line in self.split("\n", include_separator=True):
19 parts = line.split("\t", include_separator=True)
20 for part in parts:
21 if part.plain.endswith("\t"):
22 part._text = [part.plain[:-1] + " "]
23 append(part)
24 pos += len(part)
25 spaces = tab_size - ((pos - 1) % tab_size) - 1
26 if spaces:
27 append(" " * spaces, _style)
28 pos += spaces
29 else:
30 append(part)
31 self._text = [result.plain]
32 self._length = len(self.plain)
33 self._spans[:] = result._spans