Cut lines range from source.
(self, begin: int, end: int, indent: int, keepLastLF: bool)
| 212 | return pos |
| 213 | |
| 214 | def getLines(self, begin: int, end: int, indent: int, keepLastLF: bool) -> str: |
| 215 | """Cut lines range from source.""" |
| 216 | line = begin |
| 217 | if begin >= end: |
| 218 | return "" |
| 219 | |
| 220 | queue = [""] * (end - begin) |
| 221 | |
| 222 | i = 1 |
| 223 | while line < end: |
| 224 | lineIndent = 0 |
| 225 | lineStart = first = self.bMarks[line] |
| 226 | last = ( |
| 227 | self.eMarks[line] + 1 |
| 228 | if line + 1 < end or keepLastLF |
| 229 | else self.eMarks[line] |
| 230 | ) |
| 231 | |
| 232 | while (first < last) and (lineIndent < indent): |
| 233 | ch = self.src[first] |
| 234 | if isStrSpace(ch): |
| 235 | if ch == "\t": |
| 236 | lineIndent += 4 - (lineIndent + self.bsCount[line]) % 4 |
| 237 | else: |
| 238 | lineIndent += 1 |
| 239 | elif first - lineStart < self.tShift[line]: |
| 240 | lineIndent += 1 |
| 241 | else: |
| 242 | break |
| 243 | first += 1 |
| 244 | |
| 245 | if lineIndent > indent: |
| 246 | # partially expanding tabs in code blocks, e.g '\t\tfoobar' |
| 247 | # with indent=2 becomes ' \tfoobar' |
| 248 | queue[i - 1] = (" " * (lineIndent - indent)) + self.src[first:last] |
| 249 | else: |
| 250 | queue[i - 1] = self.src[first:last] |
| 251 | |
| 252 | line += 1 |
| 253 | i += 1 |
| 254 | |
| 255 | return "".join(queue) |
| 256 | |
| 257 | def is_code_block(self, line: int) -> bool: |
| 258 | """Check if line is a code block, |
no test coverage detected