Skip to content

Commit ca2cc31

Browse files
committed
fix: prevent potential class cast exception
1 parent 55f6e6c commit ca2cc31

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

plugin/src/main/java/de/sebthom/eclipse/findview/SearchReplaceEngine.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.eclipse.core.runtime.NullProgressMonitor;
1717
import org.eclipse.jdt.annotation.Nullable;
1818
import org.eclipse.jface.text.BadLocationException;
19+
import org.eclipse.jface.text.ITextSelection;
1920
import org.eclipse.jface.text.Position;
2021
import org.eclipse.jface.text.TextSelection;
2122
import org.eclipse.jface.util.PropertyChangeEvent;
@@ -150,7 +151,9 @@ public synchronized void replaceCurrentSelection() {
150151
return;
151152

152153
final var selProvider = editor.getSelectionProvider();
153-
final var sel = (TextSelection) selProvider.getSelection();
154+
final var selection = selProvider.getSelection();
155+
if (!(selection instanceof ITextSelection sel))
156+
return;
154157
if (sel.isEmpty() || sel.getLength() == 0)
155158
return;
156159

0 commit comments

Comments
 (0)