Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit366c0e2

Browse files
anthonyxdarkwing
authored andcommitted
[SourcesTree] Sort SourcesTree by url when files share same name (#8175)
1 parent62c8117 commit366c0e2

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

‎src/utils/sources-tree/addToTree.js‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ function findOrCreateNode(
4848
part:string,
4949
index:number,
5050
url:Object,
51-
debuggeeHost: ?string
51+
debuggeeHost: ?string,
52+
source:Source
5253
):TreeDirectory{
5354
constaddedPartIsFile=partIsFile(index,parts,url);
5455

@@ -69,7 +70,12 @@ function findOrCreateNode(
6970

7071
// if we have a naming conflict, we'll create a new node
7172
if(child.type==="source"||(!childIsFile&&addedPartIsFile)){
72-
returncreateNodeInTree(part,path,subTree,childIndex);
73+
// pass true to findNodeInContents to sort node by url
74+
const{index:insertIndex}=findNodeInContents(
75+
subTree,
76+
createTreeNodeMatcher(part,!addedPartIsFile,debuggeeHost,source,true)
77+
);
78+
returncreateNodeInTree(part,path,subTree,insertIndex);
7379
}
7480

7581
// if there is no naming conflict, we can traverse into the child
@@ -83,7 +89,8 @@ function findOrCreateNode(
8389
functiontraverseTree(
8490
url:ParsedURL,
8591
tree:TreeDirectory,
86-
debuggeeHost: ?string
92+
debuggeeHost: ?string,
93+
source:Source
8794
):TreeNode{
8895
constparts=url.path.split("/").filter(p=>p!=="");
8996
parts.unshift(url.group);
@@ -99,7 +106,8 @@ function traverseTree(
99106
part,
100107
index,
101108
url,
102-
debuggeeHostIfRoot
109+
debuggeeHostIfRoot,
110+
source
103111
);
104112
},tree);
105113
}
@@ -166,7 +174,7 @@ export function addToTree(
166174
return;
167175
}
168176

169-
constfinalNode=traverseTree(url,tree,debuggeeHost);
177+
constfinalNode=traverseTree(url,tree,debuggeeHost,source);
170178

171179
// $FlowIgnore
172180
finalNode.contents=addSourceToNode(finalNode,url,source);

‎src/utils/sources-tree/treeOrder.js‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { nodeHasChildren } from "./utils";
1010

1111
importtype{TreeNode}from"./types";
1212

13+
importtype{Source}from"../../types";
14+
1315
/*
1416
* Gets domain from url (without www prefix)
1517
*/
@@ -94,7 +96,9 @@ function createTreeNodeMatcherWithDebuggeeHost(
9496
functioncreateTreeNodeMatcherWithNameAndOther(
9597
part:string,
9698
isDir:boolean,
97-
debuggeeHost: ?string
99+
debuggeeHost: ?string,
100+
source?:Source,
101+
sortByUrl?:boolean
98102
):FindNodeInContentsMatcher{
99103
return(node:TreeNode)=>{
100104
if(node.name===IndexName){
@@ -109,6 +113,9 @@ function createTreeNodeMatcherWithNameAndOther(
109113
}elseif(!nodeIsDir&&isDir){
110114
return1;
111115
}
116+
if(sortByUrl&&node.type==="source"&&source){
117+
returnnode.contents.url.localeCompare(source.url);
118+
}
112119

113120
returnnode.name.localeCompare(part);
114121
};
@@ -125,7 +132,9 @@ function createTreeNodeMatcherWithNameAndOther(
125132
exportfunctioncreateTreeNodeMatcher(
126133
part:string,
127134
isDir:boolean,
128-
debuggeeHost: ?string
135+
debuggeeHost: ?string,
136+
source?:Source,
137+
sortByUrl?:boolean
129138
):FindNodeInContentsMatcher{
130139
if(part===IndexName){
131140
// Specialied matcher, when we are looking for "(index)" position.
@@ -138,5 +147,11 @@ export function createTreeNodeMatcher(
138147
}
139148

140149
// Rest of the cases, without mentioned above.
141-
returncreateTreeNodeMatcherWithNameAndOther(part,isDir,debuggeeHost);
150+
returncreateTreeNodeMatcherWithNameAndOther(
151+
part,
152+
isDir,
153+
debuggeeHost,
154+
source,
155+
sortByUrl
156+
);
142157
}

‎test/mochitest/browser_dbg-sources-querystring.js‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ add_task(async function() {
2727

2828
constlabels=[getLabel(dbg,4),getLabel(dbg,3)];
2929
is(
30-
labels.includes("simple1.js?x=1")&&labels.includes("simple1.js?x=2"),
31-
true,
32-
"simple1.js?x=1 and simple2.jsx=2 exist"
30+
getLabel(dbg,3),
31+
"simple1.js?x=1",
32+
"simple1.js?x=1 exists"
33+
);
34+
is(
35+
getLabel(dbg,4),
36+
"simple1.js?x=2",
37+
"simple1.js?x=2 exists"
3338
);
3439

3540
constsource=findSource(dbg,"simple1.js?x=1");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp