icecoder / ICEcoder

Browser code editor awesomeness
http://icecoder.net
Other
1.41k stars 348 forks source link

Format on save issue #1008

Open lukehaas opened 2 years ago

lukehaas commented 2 years ago

The following code, when formatted on save will cause duplicate lines to be inserted:

Before:


let arr = [1,2,3];

arr.indexOf(1)

let cplxArr = [
  {id: 1},
  {id: 2},
  {id: 3}
];

cplxArr.findIndex(el => el.id === 1);

after:


let arr = [1, 2, 3];

arr.indexOf(1);
arr.indexOf(1)
let cplxArr = [{ id: 1 }, { id: 2 }, { id: 3 }];
let cplxArr = [
cplxArr.findIndex((el) => el.id === 1);

This is possibly due to the diffing code here: https://github.com/icecoder/ICEcoder/blob/51cf24b2a39138e6a7b5739ef59eb38cd7c39763/assets/js/icecoder.js#L2180-L2227