Skip to content

Commit 8c62e0e

Browse files
Add LengthInBufferCells implementation (#1571)
Without redirecting this call to `internalRawUI` any formatting with ANSI escapes will likely be truncated in the wrong spot
1 parent 53b3952 commit 8c62e0e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

Diff for: src/PowerShellEditorServices/Services/PowerShellContext/Session/Host/TerminalPSHostRawUserInterface.cs

+47
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,53 @@ public override void SetBufferContents(
265265
this.internalRawUI.SetBufferContents(origin, contents);
266266
}
267267

268+
/// <summary>
269+
/// Determines the number of BufferCells a character occupies.
270+
/// </summary>
271+
/// <param name="source">
272+
/// The character whose length we want to know.
273+
/// </param>
274+
/// <returns>
275+
/// The length in buffer cells according to the original host
276+
/// implementation for the process.
277+
/// </returns>
278+
public override int LengthInBufferCells(char source)
279+
{
280+
return this.internalRawUI.LengthInBufferCells(source);
281+
}
282+
/// <summary>
283+
/// Determines the number of BufferCells a string occupies.
284+
/// </summary>
285+
/// <param name="source">
286+
/// The string whose length we want to know.
287+
/// </param>
288+
/// <returns>
289+
/// The length in buffer cells according to the original host
290+
/// implementation for the process.
291+
/// </returns>
292+
public override int LengthInBufferCells(string source)
293+
{
294+
return this.internalRawUI.LengthInBufferCells(source);
295+
}
296+
297+
/// <summary>
298+
/// Determines the number of BufferCells a substring of a string occupies.
299+
/// </summary>
300+
/// <param name="source">
301+
/// The string whose substring length we want to know.
302+
/// </param>
303+
/// <param name="offset">
304+
/// Offset where the substring begins in <paramref name="source"/>
305+
/// </param>
306+
/// <returns>
307+
/// The length in buffer cells according to the original host
308+
/// implementation for the process.
309+
/// </returns>
310+
public override int LengthInBufferCells(string source, int offset)
311+
{
312+
return this.internalRawUI.LengthInBufferCells(source, offset);
313+
}
314+
268315
#endregion
269316

270317
/// <summary>

0 commit comments

Comments
 (0)