jEdit Community - Resources for users of the jEdit Text Editor
for long lines macro generate Error - Array index out of range: 3
Submitted by Anonymous on Monday, 18 October, 2004 - 17:10
Why this macro generate Error?


__________________________________________________________
I write this macro:
// Delete 3 chars at start of line for all except first line
// delete lines longer then 930 characters

textArea.goToBufferStart(false);
textArea.goToNextLine(false);

int textAreagetLineCount=textArea.getLineCount();
java.lang.String pos ="";

for(int j = 0; j < textAreagetLineCount; ++j)
{
textArea.goToNextCharacter(false);
textArea.goToNextCharacter(false);
textArea.goToNextCharacter(false);
textArea.deleteToStartOfLine();

textArea.goToStartOfLine(false);

if(textArea.getLineLength(j) >= 930)
{
textArea.deleteLine();

}
textArea.goToNextLine(false);
textArea.goToStartOfLine(false);
}
buffer.save(view,null,true);
jEdit.closeBuffer(view,buffer);









__________________________________________________________
and example of file:
----Begin of file---
title
g line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long lineg line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long lineg line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line
g line long line long line long line
---End of file---







__________________________________________________________
produce this error:
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 3

at org.gjt.sp.jedit.Buffer.getLineEndOffset(Buffer.java:935)

at org.gjt.sp.jedit.Buffer.getLineLength(Buffer.java:958)

at org.gjt.sp.jedit.textarea.JEditTextArea.getLineLength(JEditTextArea.java:1280)

at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at bsh.Reflect.invokeOnMethod(Reflect.java:149)

at bsh.Reflect.invokeObjectMethod(Reflect.java:81)

at bsh.Name.invokeMethod(Name.java:856)

at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:72)

at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)

at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)

at bsh.BSHBinaryExpression.eval(BSHBinaryExpression.java:52)

at bsh.BSHIfStatement.evaluateCondition(BSHIfStatement.java:63)

at bsh.BSHIfStatement.eval(BSHIfStatement.java:46)

at bsh.BSHBlock.evalBlock(BSHBlock.java:130)

at bsh.BSHBlock.eval(BSHBlock.java:80)

at bsh.BSHBlock.eval(BSHBlock.java:46)

at bsh.BSHForStatement.eval(BSHForStatement.java:111)

at bsh.Interpreter.eval(Interpreter.java:641)

at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:355)

at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:284)

at org.gjt.sp.jedit.BeanShell.runScript(BeanShell.java:210)

at org.gjt.sp.jedit.Macros$BeanShellHandler.runMacro(Macros.java:990)

at org.gjt.sp.jedit.Macros$Macro.invoke(Macros.java:417)

at org.gjt.sp.jedit.gui.InputHandler.invokeAction(InputHandler.java:229)

at org.gjt.sp.jedit.jEdit$3.invokeAction(jEdit.java:2910)

at org.gjt.sp.jedit.EditAction$Wrapper.actionPerformed(EditAction.java:216)

at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

at javax.swing.AbstractButton.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI$MenuDragMouseHandler.menuDragMouseReleased(Unknown Source)

at javax.swing.JMenuItem.fireMenuDragMouseReleased(Unknown Source)

at javax.swing.JMenuItem.processMenuDragMouseEvent(Unknown Source)

at javax.swing.JMenuItem.processMouseEvent(Unknown Source)

at javax.swing.MenuSelectionManager.processMouseEvent(Unknown Source)

at javax.swing.plaf.basic.BasicMenuUI$MouseInputHandler.mouseReleased(Unknown Source)

at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)

at java.awt.Component.processMouseEvent(Unknown Source)

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.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(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.pumpOneEventForHierarchy(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)
User login
Browse archives
« November 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300