Add label.set_text_font_family, label.set_text_formatting and label.new text_formatting - #306
Merged
Merged
Conversation
…ew text_formatting label.set_text_font_family() and label.set_text_formatting() could not be called from scripts: LabelHelper had no namespace-level setters and Context did not bind them, so scripts threw "label.set_text_font_family is not a function". label.new() also ignored the v6 `text_formatting` argument. Mirrors the existing box implementation: setters on LabelHelper bound in Context, `text_formatting` stored on LabelObject (constructor, copy() and plot data), and the LabelObject method-call delegates now route through the helper. API coverage docs updated. Found in 7 of 729 popular open-source TradingView indicators; 5 of them run without errors with this change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
recheck |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
label.set_text_font_family()andlabel.set_text_formatting()cannot be called from scripts.LabelHelperhas no namespace-level setters for them, andContextdoes not bind them. (LabelObjectdid haveset_text_font_family, but only as a method.)label.new()also ignores the v6text_formattingargument.→
TypeError: label.set_text_font_family is not a functionThis script compiles on TradingView. 7 of 729 popular open-source indicators failed on this.
Fix
This mirrors the existing
boximplementation:set_text_font_familyandset_text_formattingtoLabelHelper, and bind them inContext.text_formattingonLabelObject(constructor,copy()andtoPlotData()). The default is"none", matchingtext.format_none.text_formattinginlabel.new(), both positionally (afterforce_overlay) and as a named argument.LabelObjectmethod delegates through the helper, like the other setters.label.md,pinescript-v6/label.json).Tests
tests/namespaces/label/label.test.ts: the two setters, plus a native Pine script coveringtext_formattinginlabel.new(), method-call syntax andlabel.copy(). The Pine script compiles on TradingView.dev(label.set_text_font_family is not a function) and pass with this change. Full suite: 1840 passed, 5 skipped, 16 todo.devand once against this branch. 5 now run without errors. 2 get past the missing setter and then stop at other unsupported features. No regressions. The only changed output values are in 6 scripts that usetimenowormath.random; their output also differs between two identicaldevruns. Output was compared with thetext_formattingkey left out, because this change adds that key to every label.The repro scripts and tooling are in https://github.com/lenstrats/pinets-compat.
🤖 Generated with Claude Code