|
1 | 1 | import { CompositeTreeNode, ITree, ITreeNodeOrCompositeTreeNode, TreeNode } from '@opensumi/ide-components'; |
2 | 2 | import { MessageType, localize } from '@opensumi/ide-core-browser'; |
3 | | -import { IRange, isDefined } from '@opensumi/ide-core-common'; |
| 3 | +import { IRange } from '@opensumi/ide-core-common'; |
4 | 4 | import { Path } from '@opensumi/ide-utils/lib/path'; |
5 | 5 | import { Range } from '@opensumi/monaco-editor-core/esm/vs/editor/common/core/range'; |
6 | 6 | import { DebugProtocol } from '@opensumi/vscode-debugprotocol/lib/debugProtocol'; |
@@ -114,19 +114,23 @@ export class ExpressionTreeService { |
114 | 114 | } |
115 | 115 |
|
116 | 116 | sortComparator(a: ITreeNodeOrCompositeTreeNode, b: ITreeNodeOrCompositeTreeNode) { |
117 | | - // 当存在 variablesReference 属性时,默认按大小进行排序 |
118 | | - if (isDefined((a as any).variablesReference) && isDefined((b as any).variablesReference)) { |
119 | | - return (a as any).variablesReference - (b as any).variablesReference; |
120 | | - } |
121 | 117 | if (a.constructor === b.constructor) { |
122 | | - return a.name > b.name ? 1 : a.name < b.name ? -1 : 0; |
| 118 | + const aName = a.displayName || a.name; |
| 119 | + const bName = b.displayName || b.name; |
| 120 | + const isASymbol = !/[a-zA-Z0-9]/.test(aName.charAt(0)); |
| 121 | + const isBSymbol = !/[a-zA-Z0-9]/.test(bName.charAt(0)); |
| 122 | + if (isASymbol && !isBSymbol) { |
| 123 | + return 1; |
| 124 | + } else if (!isASymbol && isBSymbol) { |
| 125 | + return -1; |
| 126 | + } |
| 127 | + return aName.localeCompare(bName, 'en', { numeric: true }) as any; |
123 | 128 | } |
124 | | - return CompositeTreeNode.is(a) ? 1 : CompositeTreeNode.is(b) ? -1 : 0; |
| 129 | + return CompositeTreeNode.is(a) ? -1 : CompositeTreeNode.is(b) ? 1 : 0; |
125 | 130 | } |
126 | 131 | } |
127 | 132 |
|
128 | 133 | export class DebugConsoleTreeService extends ExpressionTreeService { |
129 | | - // 按照默认次序排序 |
130 | 134 | sortComparator(a: ITreeNodeOrCompositeTreeNode, b: ITreeNodeOrCompositeTreeNode) { |
131 | 135 | if (!a) { |
132 | 136 | return 1; |
|
0 commit comments