Skip to content

Conversation

Copy link

Copilot AI commented Jan 16, 2026

Extends string padding functions with an optional third parameter for custom padding characters (defaulting to space), adds a new padBoth function for center-aligned padding, and adds an optional second parameter to trim for specifying custom characters to trim.

Changes

  • padLeft(str, len, padChar?) - Now accepts optional padding character
  • padRight(str, len, padChar?) - Now accepts optional padding character
  • padBoth(str, len, padChar?) - New function that pads both sides; extra character goes right on odd counts
  • trim(str, chars?) - Now accepts optional characters to trim (instead of only whitespace)

Example

parser.evaluate('padLeft("5", 3, "0")');    // "005"
parser.evaluate('padRight("5", 3, "0")');   // "500"
parser.evaluate('padBoth("hi", 6, "-")');   // "--hi--"
parser.evaluate('padBoth("hi", 5)');        // " hi  " (odd padding)
parser.evaluate('trim("**hello**", "*")');  // "hello"

Files Modified

  • src/functions/string/operations.ts - Implementation + validation for optional parameters
  • src/parsing/parser.ts - Register padBoth
  • src/language-service/language-service.documentation.ts - LSP docs for padBoth and trim
  • docs/syntax.md - User documentation
  • test/functions/functions-string.ts - Unit tests for all scenarios
Original prompt

The "padLeft" and "padRight" functions should accept a third optional parameter which specifies the padding character. The default, if none is given, should be a space. Include unit test cases and update the documentation. Also introduce a "padBoth" functions that adds padding to both sides of the string.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…h function

Co-authored-by: Sander-Toonen <5106372+Sander-Toonen@users.noreply.github.com>
Copilot AI changed the title [WIP] Add padding character option to padLeft and padRight functions Add optional padding character to padLeft/padRight and new padBoth function Jan 16, 2026
Copilot AI requested a review from Sander-Toonen January 16, 2026 12:13
@Sander-Toonen Sander-Toonen marked this pull request as ready for review January 16, 2026 12:21
@Sander-Toonen
Copy link

@copilot Also add an optional third parameter to the "trim" function.

Co-authored-by: Sander-Toonen <5106372+Sander-Toonen@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 16, 2026

@copilot Also add an optional third parameter to the "trim" function.

Added optional second parameter to trim(str, chars?) in commit a75bee0. The function now trims the specified characters instead of whitespace when provided. Example: trim("**hello**", "*") returns "hello".

Copilot AI changed the title Add optional padding character to padLeft/padRight and new padBoth function Add optional padding character to padLeft/padRight, new padBoth function, and optional chars parameter to trim Jan 16, 2026
@Sander-Toonen Sander-Toonen merged commit 37e2933 into master Jan 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants