MCPcopy Create free account
hub / github.com/tree-sitter/tree-sitter-javascript / LineNumberComponent

Class LineNumberComponent

examples/text-editor-component.js:3358–3402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3356}
3357
3358class LineNumberComponent {
3359 constructor (props) {
3360 const {className, width, marginTop, bufferRow, screenRow, number, nodePool} = props
3361 this.props = props
3362 const style = {width: width + 'px'}
3363 if (marginTop != null && marginTop > 0) style.marginTop = marginTop + 'px'
3364 this.element = nodePool.getElement('DIV', className, style)
3365 this.element.dataset.bufferRow = bufferRow
3366 this.element.dataset.screenRow = screenRow
3367 if (number) this.element.appendChild(nodePool.getTextNode(number))
3368 this.element.appendChild(nodePool.getElement('DIV', 'icon-right', null))
3369 }
3370
3371 destroy () {
3372 this.element.remove()
3373 this.props.nodePool.release(this.element)
3374 }
3375
3376 update (props) {
3377 const {nodePool, className, width, marginTop, bufferRow, screenRow, number} = props
3378
3379 if (this.props.bufferRow !== bufferRow) this.element.dataset.bufferRow = bufferRow
3380 if (this.props.screenRow !== screenRow) this.element.dataset.screenRow = screenRow
3381 if (this.props.className !== className) this.element.className = className
3382 if (this.props.width !== width) this.element.style.width = width + 'px'
3383 if (this.props.marginTop !== marginTop) {
3384 if (marginTop != null) {
3385 this.element.style.marginTop = marginTop + 'px'
3386 } else {
3387 this.element.style.marginTop = ''
3388 }
3389 }
3390 if (this.props.number !== number) {
3391 if (number) {
3392 this.element.insertBefore(nodePool.getTextNode(number), this.element.firstChild)
3393 } else {
3394 const numberNode = this.element.firstChild
3395 numberNode.remove()
3396 nodePool.release(numberNode)
3397 }
3398 }
3399
3400 this.props = props
3401 }
3402}
3403
3404class CustomGutterComponent {
3405 constructor (props) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…