boolean (EditorAndState pair, boolean onlyIfDiffers) { // editor can be invalid if underlying file is deleted during undo (e.g. after undoing scratch file creation) if (pair == null || myEditor == null || !myEditor.isValid() || !pair.canBeAppliedTo(myEditor)) return false; FileEditorState stateToRestore = pair.getState(); // If current editor state isn't equals to remembered state then // we have to try to restore previous state. But sometime it's // not possible to restore it. For example, it's not possible to // restore scroll proportion if editor doesn not have scrolling any more. FileEditorState currentState = myEditor.getState(FileEditorStateLevel.UNDO); if (onlyIfDiffers && currentState.equals(stateToRestore)) { return false; } myEditor.setState(stateToRestore); FileEditorState newState = myEditor.getState(FileEditorStateLevel.UNDO); return newState.equals(stateToRestore); }