mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
# Backport This will backport the following commits from `main` to `8.17`: - [[ES|QL] Fixes the multiple comments bug (#203966)](https://github.com/elastic/kibana/pull/203966) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Stratoula Kalafateli","email":"efstratia.kalafateli@elastic.co"},"sourceCommit":{"committedDate":"2024-12-12T11:08:29Z","message":"[ES|QL] Fixes the multiple comments bug (#203966)\n\n## Summary\r\n\r\n\r\n\r\n\r\nSometimes commenting multiple lines doesnt work as expected.\r\n\r\nThis PR fixes it. The problem was that we were (un)commenting line by\r\nline and this apparently can be buggy. With this PR we gather the edits\r\nand apply all of them in one `executeEdits `","sha":"9edadfdc4637b2fccc925677f9977fde62849608","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","Feature:ES|QL","Team:ESQL","backport:version","v8.17.0","v8.18.0"],"title":"[ES|QL] Fixes the multiple comments bug","number":203966,"url":"https://github.com/elastic/kibana/pull/203966","mergeCommit":{"message":"[ES|QL] Fixes the multiple comments bug (#203966)\n\n## Summary\r\n\r\n\r\n\r\n\r\nSometimes commenting multiple lines doesnt work as expected.\r\n\r\nThis PR fixes it. The problem was that we were (un)commenting line by\r\nline and this apparently can be buggy. With this PR we gather the edits\r\nand apply all of them in one `executeEdits `","sha":"9edadfdc4637b2fccc925677f9977fde62849608"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203966","number":203966,"mergeCommit":{"message":"[ES|QL] Fixes the multiple comments bug (#203966)\n\n## Summary\r\n\r\n\r\n\r\n\r\nSometimes commenting multiple lines doesnt work as expected.\r\n\r\nThis PR fixes it. The problem was that we were (un)commenting line by\r\nline and this apparently can be buggy. With this PR we gather the edits\r\nand apply all of them in one `executeEdits `","sha":"9edadfdc4637b2fccc925677f9977fde62849608"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
This commit is contained in:
parent
ebdcdd1c6f
commit
34c9ed88ff
1 changed files with 11 additions and 11 deletions
|
@ -169,25 +169,25 @@ export const ESQLEditor = memo(function ESQLEditor({
|
|||
const currentSelection = editor1?.current?.getSelection();
|
||||
const startLineNumber = currentSelection?.startLineNumber;
|
||||
const endLineNumber = currentSelection?.endLineNumber;
|
||||
const edits = [];
|
||||
if (startLineNumber && endLineNumber) {
|
||||
for (let lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
|
||||
const lineContent = editorModel.current?.getLineContent(lineNumber) ?? '';
|
||||
const hasComment = lineContent?.startsWith('//');
|
||||
const commentedLine = hasComment ? lineContent?.replace('//', '') : `//${lineContent}`;
|
||||
|
||||
// executeEdits allows to keep edit in history
|
||||
editor1.current?.executeEdits('comment', [
|
||||
{
|
||||
range: {
|
||||
startLineNumber: lineNumber,
|
||||
startColumn: 0,
|
||||
endLineNumber: lineNumber,
|
||||
endColumn: (lineContent?.length ?? 0) + 1,
|
||||
},
|
||||
text: commentedLine,
|
||||
edits.push({
|
||||
range: {
|
||||
startLineNumber: lineNumber,
|
||||
startColumn: 0,
|
||||
endLineNumber: lineNumber,
|
||||
endColumn: (lineContent?.length ?? 0) + 1,
|
||||
},
|
||||
]);
|
||||
text: commentedLine,
|
||||
});
|
||||
}
|
||||
// executeEdits allows to keep edit in history
|
||||
editor1.current?.executeEdits('comment', edits);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue