henrikruscon / hyper-statusline

Status Line Plugin for Hyper
MIT License
386 stars 79 forks source link

Not playing nice with other plugins #86

Open rolurq opened 5 years ago

rolurq commented 5 years ago

This plugin decorates the Hyper component, however, it takes from the props the customChildren and adds its components but then puts them in the customInnerChildren prop, here:

render() {
    const { customChildren } = this.props
    const existingChildren = customChildren ? customChildren instanceof Array ? customChildren : [customChildren] : [];

    return (
        React.createElement(Hyper, Object.assign({}, this.props, {
            customInnerChildren: existingChildren.concat(React.createElement('footer', { className: 'footer_footer' },
                React.createElement('div', { className: 'footer_group group_overflow' },
                    React.createElement('div', { className: 'component_component component_cwd' },
                        React.createElement('div', { className: 'component_item item_icon item_cwd item_clickable', title: this.state.cwd, onClick: this.handleCwdClick, hidden: !this.state.cwd }, this.state.cwd ? tildify(String(this.state.cwd)) : '')
                    )
                ),
                React.createElement('div', { className: 'footer_group' },
                    React.createElement('div', { className: 'component_component component_git' },
                        React.createElement('div', { className: `component_item item_icon item_branch ${this.state.remote ? 'item_clickable' : ''}`, title: this.state.remote, onClick: this.handleBranchClick, hidden: !this.state.branch }, this.state.branch),
                        React.createElement('div', { className: 'component_item item_icon item_number item_dirty', title: `${this.state.dirty} dirty ${this.state.dirty > 1 ? 'files' : 'file'}`, hidden: !this.state.dirty }, this.state.dirty),
                        React.createElement('div', { className: 'component_item item_icon item_number item_ahead', title: `${this.state.ahead} ${this.state.ahead > 1 ? 'commits' : 'commit'} ahead`, hidden: !this.state.ahead }, this.state.ahead)
                    )
                )
            ))
        }))
    );
}

The problem with this, is that if other plugin decorates this component, if it uses customInnerChildren the elements it puts there will be ignored, because this plugin overwrites completely that property; and if it uses customChildren, the components the other plugin puts there will be rendered twice, because this plugin takes that property and joins them in the customInnerChildren.