fix: honor selected EOL sequence when copying query text to clipboard (#10160)

getSelectionFromState() joined ranges with the chosen EOL but sliced
each range via state.sliceDoc(), which always uses the document's
own \n regardless of the LF/CRLF preference. Introduced in #8691
when the copy path switched from doc.sliceString(..., lineSep) to
sliceDoc(...) to fix multi-cursor copying.

Slice with state.doc.sliceString(range.from, range.to, lineSep) so
the chosen EOL applies within a range too; the #8691 multi-cursor
join behavior is unchanged.

Fixes #10158
This commit is contained in:
hiteshjambhale
2026-07-24 18:13:27 +05:30
committed by GitHub
parent cec1b38b2f
commit f9935b3da5
@@ -306,7 +306,7 @@ export default class CustomEditorView extends EditorView {
static getSelectionFromState(state) {
// function to get selection from EditorState
const lineSep = state.facet(eol);
return state.selection.ranges.map((range)=>state.sliceDoc(range.from, range.to)).join(lineSep) ?? '';
return state.selection.ranges.map((range)=>state.doc.sliceString(range.from, range.to, lineSep)).join(lineSep) ?? '';
}
replaceSelection(newValue) {