title: onEdit function inserts more rows than coded for
body: <p>My code is inside a Google Sheets file in my Google Drive:</p>
  <p><a href="https://docs.google.com/spreadsheets/d/1lrxNzCmK4v2OOV3bmzCT_IGbJe30JjPP-7_JSEGWPjY/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1lrxNzCmK4v2OOV3bmzCT_IGbJe30JjPP-7_JSEGWPjY/edit?usp=sharing</a></p>
  <p>I've copied them here in case there are changes to the Google Sheets file or if you can't access it.  I want to insert 6 blank rows to part a few rows of data in the spreadsheet, but instead of 6 rows, the GAS interpreter inserts 12 rows instead.  Does anyone know why this happens and how to resolve it?</p>
  <pre><code>function onEdit(e) {
    let c = e.range
      , cellrow = c.getRowIndex()
      , cellcol = c.getColumnIndex()
      , c2
      sheet = SpreadsheetApp.getActiveSheet()
      ;
    /* code to part sea of words in spreadsheet */
    let cvalue = c.getValue();
    if (cvalue == &quot;EVERY&quot; || cvalue == &quot;PARTY&quot;) {
      let [upper, left, right, lower] = checkNeighbours(c);
      let neighbours = [upper, left, right, lower]
      if (! allBlank(neighbours)) {
        // insert 6 rows and delete original word at original position
        c.getSheet().insertRowsAfter(c.getRowIndex(), 6);
        c.setValue(&quot;&quot;);
        // paste original word in cell 2 rows below original position
        cellrow += 2;
        c2 = sheet.getRange(cellrow, cellcol);
        c2.setValue(cvalue);
      }
    }
  }
  // return the (up to) 8 cells surrounding cell c
  function checkNeighbours(c) {
    let nbUpperRow = c.offset(-1,-2,1,8)
        , nbLeft = c.offset(0,-2,1,2)
        , nbRight = c.offset(0,1,1,5)
        , nbLowerRow = c.offset(1,-2,3,8)
        ;
    return [nbUpperRow, nbLeft, nbRight, nbLowerRow];
  }
  // are all the cells given, blank?
  function allBlank(rs) {
    for (var c of rs) {
      if (! c.isBlank()) return false;
    }
    return true;
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/uFLhX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uFLhX.png" alt="View of Spreadsheet before insert 6 rows" /></a>
  <a href="https://i.stack.imgur.com/LjMDY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LjMDY.png" alt="View of Spreadsheet after insert 6 rows" /></a></p>