I've added PHP markers in a new buffer ("<?php .. ?>" - on lines by itself), pasted about 230 lines between it, attempted to save it, but canceled this.
Then I've cut the text again, the gutter displays now only line 2 and 3, but no scrollbar.
Line 1 should contain "<?php", line 2 is empty and line 3 contains "?>".
When I attempt to scroll to line 1 (I've intentionally done Ctrl-Pos1), the following backtrace occurs:
java.lang.NullPointerException
at org.gjt.sp.jedit.textarea.TextArea.scrollTo(TextArea.java:870)
at org.gjt.sp.jedit.textarea.TextArea.scrollToCaret(TextArea.java:727)
at org.gjt.sp.jedit.textarea.TextArea._finishCaretUpdate(TextArea.java:4891)
at org.gjt.sp.jedit.textarea.TextArea.finishCaretUpdate(TextArea.java:5077)
at org.gjt.sp.jedit.textarea.TextArea.moveCaretPosition(TextArea.java:2225)
at org.gjt.sp.jedit.textarea.TextArea.moveCaretPosition(TextArea.java:2192)
at org.gjt.sp.jedit.textarea.TextArea.moveCaretPosition(TextArea.java:2182)
at org.gjt.sp.jedit.textarea.TextArea._changeLine(TextArea.java:5190)
at org.gjt.sp.jedit.textarea.TextArea.goToPrevLine(TextArea.java:2743)
at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.gjt.sp.jedit.bsh.Reflect.invokeMethod(Reflect.java:134)
at org.gjt.sp.jedit.bsh.Reflect.invokeObjectMethod(Reflect.java:80)
at org.gjt.sp.jedit.bsh.Name.invokeMethod(Name.java:855)
at org.gjt.sp.jedit.bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:75)
at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
at org.gjt.sp.jedit.bsh.BSHBlock.evalBlock(BSHBlock.java:130)
at org.gjt.sp.jedit.bsh.BSHBlock.eval(BSHBlock.java:80)
at org.gjt.sp.jedit.bsh.BshMethod.invokeImpl(BshMethod.java:362)
at org.gjt.sp.jedit.bsh.BshMethod.invoke(BshMethod.java:258)
at org.gjt.sp.jedit.bsh.BshMethod.invoke(BshMethod.java:186)
at org.gjt.sp.jedit.BeanShellFacade.runCachedBlock(BeanShellFacade.java:225)
at org.gjt.sp.jedit.BeanShell.runCachedBlock(BeanShell.java:423)
at org.gjt.sp.jedit.BeanShellAction.invoke(BeanShellAction.java:73)
at org.gjt.sp.jedit.gui.InputHandler.invokeAction(InputHandler.java:352)
at org.gjt.sp.jedit.gui.InputHandler.invokeAction(InputHandler.java:317)
at org.gjt.sp.jedit.gui.DefaultInputHandler.handleKey(DefaultInputHandler.java:197)
at firstmate.FirstMateInputHandler.handleKey(FirstMateInputHandler.java:201)
at org.gjt.sp.jedit.input.AbstractInputHandler.processKeyEventKeyStrokeHandling(AbstractInputHandler.java:405)
at org.gjt.sp.jedit.gui.InputHandler.processKeyEvent(InputHandler.java:151)
at org.gjt.sp.jedit.textarea.TextArea.processKeyEvent(TextArea.java:4525)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
The problem appears to be, that after cutting the block of text, line 1 is not visible. When I undo all changes, I end up in line 1 apparently, but it's still not visible and pressing Ctrl-Pos1 (or cursor-up) produces the NPE.
This appears to be some corner case, since it's not easily reproducible and depends probably on the height of the buffer view and the text being cut/removed.
This is with jEdit trunk, r14969.
I'm marking this as "regressive", since I've not had something similar for a long time.
I recall another ticket was opened about line count being confused after a multiline paste followed by an undo. I thought it was closed/fixed though. If I can find it I will link it to this one, but it sounds like the same old bug to me.
Alan, please note that this was not caused by "Undo" (IIRC), but only by cutting a block of text:
after the text had been removed, only three lines were left (but the first one was no visible, although the view area had space for 20+ lines).
dupe of 1973498