   onbeforeunload: -> # called when the user presses [X] on the OS window
     if @ide.dead
       D.forceCloseNWWindow?(); return
-    else if @cm.getValue() == @originalText && @breakpoints.join() == @originalBreakpoints
+    else if @cm.getValue() == @otext && @bp.join() == @obp
       @EP(); return
     else if !@dialog
       window.focus()

    for sel in @cm.listSelections()
      l0 = sel.anchor.line; l1 = sel.head.line; if l0 > l1 then tmp = l0; l0 = l1; l1 = tmp
      for l in [l0..l1] by 1
        if (i = @breakpoints.indexOf l) >= 0 then @breakpoints.splice i, 1; @cm.setGutterMarker l, 'breakpoints', null
        else @breakpoints.push l; @cm.setGutterMarker l, 'breakpoints', @createBreakpointElement()
    if @isTracer
      @emit 'SetLineAttributes', win: @id, nLines: @cm.lineCount(), lineAttributes: stop: @breakpoints[..].sort (x, y) -> x - y
    return
  tabOrAutocomplete: ->
    if @cm.somethingSelected()

    $r.focus().select(); @highlightSearch(); return
  EP: ->
    v = @cm.getValue()
    if v != @otext || @bp.join() != @obp
      for l in @bp then @cm.setGutterMarker l, 'breakpoints', null
      @emit 'SaveChanges', win: @id, text: @cm.getValue(), attributes: stop: @bp[..].sort (x, y) -> x - y
    else
      @emit 'CloseWindow', win: @id
    return
