Skip to content

Commit

Permalink
Update io.py
Browse files Browse the repository at this point in the history
Always set is_first_char[file] to True, igrone space problem
(Review from PR)
  • Loading branch information
OranPie authored Oct 4, 2024
1 parent c71ff67 commit 8b0cc65
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions cyaron/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ def __write(self, file: IOBase, *args, **kwargs):
if arg == "\n":
self.is_first_char[file] = True

def __clear_last_space(self, file: IOBase):
"""
Clear the last space(s) use truncate()
Args:
file:Which file to clear
"""
while True:


def __clear(self, file: IOBase, pos: int = 0):
"""
Clear the content use truncate()
Expand All @@ -207,15 +216,7 @@ def __clear(self, file: IOBase, pos: int = 0):
pos: Where file will truncate.
"""
file.truncate(pos)
if pos == 0: # 重置self.is_first_char
self.is_first_char[file] = True
else:
file.seek(pos - 1)
if file.read(1) != " ": # 若不是空格 重置self.is_first_char
self.is_first_char[file] = False
else:
self.is_first_char[file] = True

self.is_first_char[file] = True
file.seek(pos)

def input_write(self, *args, **kwargs):
Expand Down

0 comments on commit 8b0cc65

Please sign in to comment.