File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -191,10 +191,13 @@ function canCrossNodeWhileReorder(node: NodeOrToken): boolean {
191191function canReorderItems ( firstNode : NodeOrToken , secondNode : NodeOrToken ) : boolean {
192192 const parent = firstNode . parent ;
193193 const firstIndex = parent . body . indexOf ( firstNode ) ;
194- const secondIndex = parent . body . indexOf ( secondNode ) ;
195- const nodesBetween = parent . body . slice ( firstIndex , secondIndex + 1 ) ;
196- for ( const nodeBetween of nodesBetween ) {
197- if ( ! canCrossNodeWhileReorder ( nodeBetween ) ) {
194+ const secondIndex = parent . body . indexOf ( secondNode , firstIndex ) ;
195+ if ( firstIndex === - 1 || secondIndex === - 1 ) {
196+ return false ;
197+ }
198+
199+ for ( let i = firstIndex ; i <= secondIndex ; i ++ ) {
200+ if ( ! canCrossNodeWhileReorder ( parent . body [ i ] ) ) {
198201 return false ;
199202 }
200203 }
You can’t perform that action at this time.
0 commit comments