Stream track current tab depth

This commit is contained in:
2024-12-11 10:53:02 -06:00
parent 6ec40da338
commit 8e3bb78829

View File

@@ -125,15 +125,20 @@ class Stream {
public function dropChars(count:Int, taking:Bool) {
for (idx in 0...count) {
switch (content.charAt(idx)) {
// newline
case "\n":
_currentTab = "";
absoluteChar += absolutePerNewline;
line += 1;
lineLengths.push(column);
column = 1;
startOfLine = true;
// other whitespace character
case c if (c.trim() == ""):
_currentTab += c;
absoluteChar += 1;
column += 1;
// non-whitespace
default:
absoluteChar += 1;
column += 1;
@@ -183,6 +188,12 @@ class Stream {
#end
}
var _currentTab = "";
public function currentTab():String {
return _currentTab;
}
public function takeChars(count:Int):Option<String> {
if (count > content.length)
return None;