fix
This commit is contained in:
@@ -43,13 +43,22 @@ class Backboard:
|
||||
f"- File tree: {self.file_tree}{endl}")
|
||||
# f"- Activated file content (current editing 10 lines): {endl}"
|
||||
def add_history(self, realtime_action):
|
||||
if(realtime_action['type']=='config'):return
|
||||
if len(self.history)!=0:
|
||||
if (self.history[-1]['type']=='fileEdit'):
|
||||
if(self.history[-1]['filePath'] == realtime_action['filePath']):
|
||||
# 检查必要的键是否存在,避免KeyError
|
||||
if realtime_action.get('type') == 'config':
|
||||
return
|
||||
if len(self.history) > 0 and realtime_action.get('type') == 'fileEdit':
|
||||
# 安全地获取filePath,并进行比较
|
||||
current_file_path = realtime_action.get('filePath')
|
||||
# 检查最近的历史记录是否包含filePath
|
||||
if current_file_path and self.history[-1].get('filePath') == current_file_path:
|
||||
# 安全地更新content,只有当content存在时才更新
|
||||
if 'content' in realtime_action:
|
||||
self.history[-1]['content'] = realtime_action['content']
|
||||
return
|
||||
return
|
||||
self.history.append(realtime_action)
|
||||
# 限制历史记录的数量
|
||||
if len(self.history) > 500: # 假设最多保留500条记录
|
||||
self.history.pop(0) # 移除最旧的记录
|
||||
|
||||
|
||||
def get_deltatime_mmss(self, start_time, end_time):
|
||||
|
||||
Reference in New Issue
Block a user