void (final int offset) { if (myPanel == null) return; // Do not scroll if html update request is online // This will restrain preview from glitches on editing if (!myPooledAlarm.isEmpty()) { myLastScrollOffset = offset; return; } synchronized (REQUESTS_LOCK) { if (mySwingAlarm.isDisposed()) { return; } if (myLastScrollRequest != null) { mySwingAlarm.cancelRequest(myLastScrollRequest); } myLastScrollRequest = () -> { if (myPanel != null) { myLastScrollOffset = offset; myPanel.scrollToMarkdownSrcOffset(myLastScrollOffset, true); synchronized (REQUESTS_LOCK) { myLastScrollRequest = null; } } }; mySwingAlarm.addRequest(myLastScrollRequest, RENDERING_DELAY_MS, ModalityState.stateForComponent(getComponent())); } }