FrankChen021 opened a new issue, #20605:
URL: https://github.com/apache/druid/issues/20605

   ### Affected Version
   
   master, since #20507.
   
   ### Description
   
   In the workbench SQL editor, the line number of a line that has (or had) a 
sub-query "run" marker repeats its digits after each edit. For example, line 6 
shows `6666666` and line 14 shows `1414`.
   
   ![Duplicated line numbers in the workbench 
editor](https://github.com/FrankChen021/druid/blob/issue-assets/issue-assets/codemirror-gutter-duplicated-line-numbers.png?raw=true)
   
   To reproduce: in the workbench, write a few queries separated by blank lines 
so they get "run" markers, then keep typing. The numbers on the marker lines 
grow by one copy per edit. Lines that never had a marker are not affected.
   
   #### Cause
   
   `SubQueryMarker.toDOM()` in 
`web-console/src/views/workbench-view/flexible-query-input/sub-query-markers.ts`
 returns a `DocumentFragment` with two nodes, the run button and the line 
number text:
   
   ```ts
   const fragment = document.createDocumentFragment();
   fragment.append(button, String(this.lineNumber));
   return fragment;
   ```
   
   CodeMirror assumes one DOM node per gutter marker: when it replaces a 
marker, `GutterElement.setMarkers` removes only the first node 
(`domPos.remove()`). The run button is removed, but the old number text node 
stays. The `subQueries` state field rebuilds the markers on every document 
change, so a marker line gains one more copy of its number with each edit.
   
   #### Suggested fix
   
   Return a single element, so CodeMirror removes the number with the button:
   
   ```ts
   const element = document.createElement('span');
   element.append(button, String(this.lineNumber));
   return element;
   ```
   
   @vogievetsky, this came in with #20507. Could you take a look?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to