Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Eclipse] Index out of bounds while drawing ghost text #3298

Open
joaodinissf opened this issue Oct 21, 2024 · 0 comments
Open

[Eclipse] Index out of bounds while drawing ghost text #3298

joaodinissf opened this issue Oct 21, 2024 · 0 comments

Comments

@joaodinissf
Copy link
Contributor

joaodinissf commented Oct 21, 2024

Describe the bug
In certain cases, Tabby makes calls to org.eclipse.swt.custom.StyledText.getLocationAtOffset(int) in which the offset argument is greater than getCharCount(). This causes an java.lang.IllegalArgumentException: Index out of bounds exception to be thrown here.

This exception may occasionally cause ghost text to be improperly rendered.

I have observed this exception occur as a result of these two function calls, at lines 331 and 416 of InlineCompletionRenderer.java:

Information about your version
Tabby for Eclipse: v0.0.2.26

Information about your GPU
N/A

Additional context

Instructions to reproduce this bug

  1. Launch the Eclipse IDE with the Tabby, create an empty project
  2. Create a file with a few lines of text (see, for example, the video attached below)
  3. Place the cursor at an empty line at the very end of the file
  4. Press the BACKSPACE and/or ENTER keys a few times in quick succession: this will trigger a re-drawing of the ghost text in such a way that this bug occurs

Video showing the bug

indexOoB.mp4

Sample stack trace 1

java.lang.IllegalArgumentException: Index out of bounds
	at org.eclipse.swt.SWT.error(SWT.java:4903)
	at org.eclipse.swt.SWT.error(SWT.java:4837)
	at org.eclipse.swt.SWT.error(SWT.java:4808)
	at org.eclipse.swt.custom.StyledText.getLocationAtOffset(StyledText.java:4015)
	at com.tabbyml.tabby4eclipse.inlineCompletion.InlineCompletionRenderer$InlineCompletionItemPainter.lambda$5(InlineCompletionRenderer.java:331)
	at com.tabbyml.tabby4eclipse.inlineCompletion.InlineCompletionRenderer$InlineCompletionItemPainter.lambda$2(Unknown Source)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at com.tabbyml.tabby4eclipse.inlineCompletion.InlineCompletionRenderer$InlineCompletionItemPainter.paintControl(Unknown Source)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:247)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4285)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1160)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1184)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1169)
	at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1540)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4769)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5050)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(Native Method)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3671)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1042)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:152)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:639)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:546)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:143)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:668)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:605)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1481)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1454)

Sample stack trace 2

java.lang.IllegalArgumentException: Index out of bounds
	at org.eclipse.swt.SWT.error(SWT.java:4903)
	at org.eclipse.swt.SWT.error(SWT.java:4837)
	at org.eclipse.swt.SWT.error(SWT.java:4808)
	at org.eclipse.swt.custom.StyledText.getLocationAtOffset(StyledText.java:4016)
	at com.tabbyml.tabby4eclipse.inlineCompletion.InlineCompletionRenderer$InlineCompletionItemPainter.lambda$7(InlineCompletionRenderer.java:416)
	at com.tabbyml.tabby4eclipse.inlineCompletion.InlineCompletionRenderer$InlineCompletionItemPainter.lambda$2(InlineCompletionRenderer.java:129)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at com.tabbyml.tabby4eclipse.inlineCompletion.InlineCompletionRenderer$InlineCompletionItemPainter.paintControl(InlineCompletionRenderer.java:128)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:247)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4326)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1174)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1198)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1183)
	at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1544)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4784)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5091)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(Native Method)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3710)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1042)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:639)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:546)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:143)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:668)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:605)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1481)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1454)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant