code: function updateMarks(editor, diff, state, type, classes) {
      var vp = editor.getViewport();
      editor.operation(function() {
        if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) {
          clearMarks(editor, state.marked, classes);
          markChanges(editor, diff, type, state.marked, vp.from, vp.to, classes);
          state.from = vp.from; state.to = vp.to;
        } else {
          if (vp.from < state.from) {
            markChanges(editor, diff, type, state.marked, vp.from, state.from, classes);
            state.from = vp.from;
          }
          if (vp.to > state.to) {
            markChanges(editor, diff, type, state.marked, state.to, vp.to, classes);
            state.to = vp.to;
          }
        }
      });
    }
docs: FIXME maybe add a margin around viewport to prevent too many updates