Merge remote-tracking branch

'origin/GP-1-dragonmacher-escape-selection-fix' (#7241)
This commit is contained in:
Ryan Kurtz 2025-06-23 12:57:13 -04:00
commit 8d95e97521

View file

@ -17,6 +17,8 @@ package ghidra.app.plugin.core.codebrowser;
import javax.swing.Icon;
import org.apache.commons.lang3.StringUtils;
import docking.action.builder.ActionBuilder;
import docking.tool.ToolConstants;
import generic.theme.GIcon;
@ -93,7 +95,7 @@ public class CodeBrowserSelectionPlugin extends Plugin {
.helpLocation(new HelpLocation(HelpTopics.SELECTION, "Clear Selection"))
.withContext(ListingActionContext.class, true)
.inWindow(ActionBuilder.When.CONTEXT_MATCHES)
.enabledWhen(c -> c.hasSelection())
.enabledWhen(c -> hasSelection(c))
.onAction(c -> ((CodeViewerProvider) c.getComponentProvider())
.setSelection(new ProgramSelection()))
.buildAndInstall(tool);
@ -191,6 +193,15 @@ public class CodeBrowserSelectionPlugin extends Plugin {
tableProvider.installRemoveItemsAction();
}
private boolean hasSelection(ListingActionContext c) {
if (c.hasSelection()) {
return true;
}
String textSelection = ((CodeViewerProvider) c.getComponentProvider()).getTextSelection();
return !StringUtils.isBlank(textSelection);
}
private GhidraProgramTableModel<Address> createTableModel(Program program,
CodeUnitIterator iterator, ProgramSelection selection) {