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

AutomationPeer editor extension #332

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ICSharpCode.AvalonEdit/Editing/TextArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,15 @@ public bool OverstrikeMode {

#endregion

#region AutomationPeer override for CodeCompletion
/// <summary>
/// Gets or sets AutomationPeer instance used by CodeCompletion.
/// CompletionWindow can use this property to inject AutomationPeer that reflects
/// the suggestion list and the value of the currently selected CompletionData item.
/// </summary>
public System.Windows.Automation.Peers.AutomationPeer CodeCompletionAutomationPeer { get; set; }
#endregion

/// <inheritdoc/>
protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
{
Expand Down
10 changes: 10 additions & 0 deletions ICSharpCode.AvalonEdit/Editing/TextRangeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public ITextRangeProvider Clone()
public bool Compare(ITextRangeProvider range)
{
TextRangeProvider other = (TextRangeProvider)range;
if (textArea.CodeCompletionAutomationPeer != null) {
Log("{0}.Compare({1}) [ActiveIntelliSenseAutomationPeer != null]= false", ID, other.ID);
return false;
}

bool result = doc == other.doc
&& segment.Offset == other.segment.Offset
&& segment.EndOffset == other.segment.EndOffset;
Expand Down Expand Up @@ -194,6 +199,11 @@ public IRawElementProviderSimple GetEnclosingElement()
public string GetText(int maxLength)
{
Log("{0}.GetText({1})", ID, maxLength);
if (textArea.CodeCompletionAutomationPeer != null) {
var result = textArea.CodeCompletionAutomationPeer.GetName();
Log("{0}.GetText({1}) --> {2}", ID, maxLength, result);
return result;
}
if (maxLength < 0)
return doc.GetText(segment);
else
Expand Down