Browse Source

ResourceLinkGenerator opts out of Ctrl+Click explicitly

AvaloniaEdit's TextEditorOptions.RequireControlModifierForHyperlinkClick
only flows into its *built-in* LinkElementGenerator (via the
IBuiltinElementGenerator.FetchOptions hook the editor calls from
UpdateBuiltinElementGeneratorsFromOptions). Subclasses added to
ElementGenerators by hand inherit whatever the parameterless base
constructor sets — which is "true" — so the editor-level flag flipped in
DecompilerTextView didn't actually reach our generator.

Assisted-by: Claude:claude-opus-4-7:Claude Code
pull/3755/head
Siegfried Pammer 2 months ago
parent
commit
53334eebcf
  1. 14
      ILSpy.Tests/Commands/HelpCommandTests.cs
  2. 7
      ILSpy/Commands/ResourceLinkGenerator.cs

14
ILSpy.Tests/Commands/HelpCommandTests.cs

@ -132,6 +132,20 @@ public class HelpCommandTests @@ -132,6 +132,20 @@ public class HelpCommandTests
licenseTab.Text.Should().Contain("Permission is hereby granted");
}
[Test]
public void ResourceLinkGenerator_Does_Not_Require_Ctrl_Modifier_For_Click()
{
// AvaloniaEdit's TextEditorOptions.RequireControlModifierForHyperlinkClick only
// propagates to the *built-in* LinkElementGenerator via IBuiltinElementGenerator.
// FetchOptions; user-added subclasses keep whatever the base parameterless ctor sets
// (default true). The About-page generator must opt out explicitly so its links
// activate on a plain click.
var gen = new ResourceLinkGenerator(
"MIT License",
new System.Uri("resource:license.txt"));
gen.RequireControlModifierForClick.Should().BeFalse();
}
[AvaloniaTest]
public async Task Decompiler_Editor_Activates_Hyperlinks_Without_Ctrl_Modifier()
{

7
ILSpy/Commands/ResourceLinkGenerator.cs

@ -36,6 +36,13 @@ namespace ILSpy.Commands @@ -36,6 +36,13 @@ namespace ILSpy.Commands
: base(new Regex(Regex.Escape(phrase)))
{
this.target = target ?? throw new ArgumentNullException(nameof(target));
// AvaloniaEdit's TextEditorOptions.RequireControlModifierForHyperlinkClick only
// propagates to its *built-in* LinkElementGenerator (via the
// IBuiltinElementGenerator.FetchOptions hook the editor invokes from
// UpdateBuiltinElementGeneratorsFromOptions). User-added subclasses inherit
// whatever the parameterless base constructor set (default true), so we have to
// opt out explicitly here.
RequireControlModifierForClick = false;
}
protected override Uri GetUriFromMatch(Match match) => target;

Loading…
Cancel
Save