(this: CharAtBlock)
| 1006 | * Does the initial mutator update of text_charAt and adds the tooltip |
| 1007 | */ |
| 1008 | const CHARAT_EXTENSION = function (this: CharAtBlock) { |
| 1009 | const dropdown = this.getField('WHERE') as FieldDropdown; |
| 1010 | dropdown.setValidator(function (this: FieldDropdown, value: any) { |
| 1011 | const newAt = value === 'FROM_START' || value === 'FROM_END'; |
| 1012 | const block = this.getSourceBlock() as CharAtBlock; |
| 1013 | if (newAt !== block.isAt_) { |
| 1014 | block.updateAt_(newAt); |
| 1015 | } |
| 1016 | return undefined; // FieldValidators can't be void. Use option as-is. |
| 1017 | }); |
| 1018 | this.updateAt_(true); |
| 1019 | this.setTooltip(() => { |
| 1020 | const where = this.getFieldValue('WHERE'); |
| 1021 | let tooltip = Msg['TEXT_CHARAT_TOOLTIP']; |
| 1022 | if (where === 'FROM_START' || where === 'FROM_END') { |
| 1023 | const msg = |
| 1024 | where === 'FROM_START' |
| 1025 | ? Msg['LISTS_INDEX_FROM_START_TOOLTIP'] |
| 1026 | : Msg['LISTS_INDEX_FROM_END_TOOLTIP']; |
| 1027 | if (msg) { |
| 1028 | tooltip += |
| 1029 | ' ' + |
| 1030 | msg.replace('%1', this.workspace.options.oneBasedIndex ? '#1' : '#0'); |
| 1031 | } |
| 1032 | } |
| 1033 | return tooltip; |
| 1034 | }); |
| 1035 | }; |
| 1036 | |
| 1037 | Extensions.register('text_indexOf_tooltip', INDEXOF_TOOLTIP_EXTENSION); |
| 1038 |
nothing calls this directly
no test coverage detected