Skip to content

Commit 1f53a59

Browse files
committed
cleanup
1 parent 8119c93 commit 1f53a59

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

Terminal.Gui/ViewBase/View.Text.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public string Text
7676

7777
SetTextDirect (value);
7878

79-
OnTextChanged ();
79+
RaiseTextChanged ();
8080
}
8181
}
8282

@@ -133,19 +133,31 @@ protected virtual bool OnTextChanging (string newText)
133133
public event EventHandler<CancelEventArgs>? TextChanging;
134134

135135
/// <summary>
136-
/// Called after the <see cref="Text"/> has been changed. Raises the <see cref="TextChanged"/> event.
136+
/// Called after the <see cref="Text"/> has been changed.
137137
/// </summary>
138138
/// <remarks>
139139
/// <para>
140-
/// This is a signal-only notification. It does not carry old or new text values because
141-
/// <see cref="View.Text"/> semantics vary across derived views.
140+
/// Override in derived views to react to text changes. The base implementation is empty.
141+
/// The <see cref="TextChanged"/> event is raised by the caller after this method returns.
142142
/// </para>
143+
/// </remarks>
144+
protected virtual void OnTextChanged () { }
145+
146+
/// <summary>
147+
/// Invokes the CWP post-change workflow for <see cref="Text"/>: calls <see cref="OnTextChanged"/>
148+
/// then raises <see cref="TextChanged"/>.
149+
/// </summary>
150+
/// <remarks>
143151
/// <para>
144-
/// Derived views that override <see cref="Text"/> and do not call <c>base.Text</c> should call
145-
/// this method after mutating text to participate in the CWP workflow.
152+
/// Derived views that bypass the base <see cref="Text"/> setter (e.g., using <c>new</c>) should
153+
/// call this method after mutating text to participate in the CWP workflow.
146154
/// </para>
147155
/// </remarks>
148-
protected virtual void OnTextChanged () => TextChanged?.Invoke (this, EventArgs.Empty);
156+
internal void RaiseTextChanged ()
157+
{
158+
OnTextChanged ();
159+
TextChanged?.Invoke (this, EventArgs.Empty);
160+
}
149161

150162
/// <summary>
151163
/// Raised after the <see cref="Text"/> has been changed.

Terminal.Gui/Views/TextInput/TextView/TextView.Text.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public int TabWidth
197197
// Keep base View._text in sync
198198
SetTextDirect (value);
199199

200-
OnTextChanged ();
200+
RaiseTextChanged ();
201201
SetNeedsDraw ();
202202

203203
_historyText.Clear (_model.GetAllLines ());

0 commit comments

Comments
 (0)