       editor.insertText "foo"
       editor.setCursorBufferPosition([0,0])
       editor.selectToEndOfLine()
-      originalSelectionRange = editor.getSelection().getBufferRange()
-      editor.save()
-      newSelectionRange = editor.getSelection().getBufferRange()
+      originalSelectionRange = editor.getLastSelection().getBufferRange()
+      editor.save()
+      newSelectionRange = editor.getLastSelection().getBufferRange()
       expect(originalSelectionRange).toEqual(newSelectionRange)
 
   describe "when 'whitespace.ensureSingleTrailingNewline' is false", ->

      editor.insertText "1  \n2\t  \n\t \n3\n"

      # move cursor to bottom for preventing effect of whitespace.ignoreWhitespaceOnCurrentLine
      editor.moveCursorToBottom()
      editor.save()
      expect(editor.getText()).toBe "1\n2\n\n3\n"


        editor = atom.workspace.open('sample.txt').then (o) -> editor = o

      runs ->
        editor.moveToEndOfLine()
        editor.insertText("           ")

        # move cursor to next line to avoid ignoreWhitespaceOnCurrentLine
        editor.moveToBottom()

        editor.save()
        expect(editor.getText()).toBe 'Some text.\n'
