File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ class GhostSuggestionFile {
77
77
}
78
78
79
79
private computeOperationsOffset ( group : GhostSuggestionEditOperation [ ] ) {
80
- return group . reduce (
80
+ const { added , removed } = group . reduce (
81
81
( acc , op ) => {
82
82
if ( op . type === "+" ) {
83
83
return { added : acc . added + 1 , removed : acc . removed }
@@ -88,18 +88,19 @@ class GhostSuggestionFile {
88
88
} ,
89
89
{ added : 0 , removed : 0 } ,
90
90
)
91
+ return { added, removed, offset : added - removed }
91
92
}
92
93
93
94
public deleteSelectedGroup ( ) {
94
95
if ( this . selectedGroup !== null && this . selectedGroup < this . groups . length ) {
95
96
const deletedGroup = this . groups . splice ( this . selectedGroup , 1 )
96
- const { removed } = this . computeOperationsOffset ( deletedGroup [ 0 ] )
97
+ const { offset } = this . computeOperationsOffset ( deletedGroup [ 0 ] )
97
98
// update deleted operations in the next groups
98
99
for ( let i = this . selectedGroup ; i < this . groups . length ; i ++ ) {
99
100
for ( let j = 0 ; j < this . groups [ i ] . length ; j ++ ) {
100
101
const op = this . groups [ i ] [ j ]
101
102
if ( op . type === "-" ) {
102
- op . line = op . line - removed
103
+ op . line = op . line + offset
103
104
}
104
105
}
105
106
}
You can’t perform that action at this time.
0 commit comments