Skip to content

Commit 46c81bc

Browse files
committed
fix: 当新增文件为最后一个时, 无法正确插入到对应位置
1 parent 5e5af8f commit 46c81bc

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

Moder.Core/Services/LocalisationKeyMappingService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ var skillType in Enums
4040
)
4141
);
4242
}
43-
43+
44+
// 突破
4445
AddKeyMapping("breakthrough_factor", new LocalisationKeyMappingConfig("MODIFIER_BREAKTHROUGH"));
4546
}
4647

Moder.Core/ViewsModels/Menus/SideWorkSpaceControlViewModel.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private static int FindInsertIndex(SystemFileItem newItem)
142142
}
143143

144144
// 如果是文件, 添加到最后一个文件之后
145-
var insertIndex = parentChildren.Count - 1;
145+
var insertIndex = parentChildren.Count;
146146
var maxIndex = parentChildren.Count;
147147
var lastFolderIndex = FindLastFolderIndex(parentChildren);
148148
var index = 0;
@@ -157,10 +157,10 @@ private static int FindInsertIndex(SystemFileItem newItem)
157157
else
158158
{
159159
// 跳过所有文件夹
160-
index = lastFolderIndex + 1;
160+
index = lastFolderIndex == 0 ? 0 : lastFolderIndex + 1;
161161
}
162162

163-
for (; index < maxIndex; index++)
163+
while (index < maxIndex)
164164
{
165165
if (
166166
WindowsStringComparer.Instance.Compare(newItem.FullPath, parentChildren[index].FullPath) == -1
@@ -169,6 +169,8 @@ private static int FindInsertIndex(SystemFileItem newItem)
169169
insertIndex = index;
170170
break;
171171
}
172+
173+
index++;
172174
}
173175

174176
return insertIndex;

0 commit comments

Comments
 (0)