From 0f629775aad0274d4ddb9515525efdaa959146eb Mon Sep 17 00:00:00 2001 From: hiteshjambhale Date: Fri, 17 Jul 2026 18:55:46 +0530 Subject: [PATCH] fix: honor selected EOL sequence when copying query text to clipboard #10158 getSelectionFromState joined selection ranges with the chosen EOL but sliced each range with sliceDoc(), which always uses the document line break (\n). For a normal single-range selection this meant line breaks were always copied as LF regardless of the LF/CRLF status-bar setting, regressing the #7393 feature. Slice each range with doc.sliceString(from, to, lineSep) so the chosen EOL is applied to line breaks within the selection as well, while still joining multiple cursor ranges with the same separator (keeping #8691). --- .../static/js/components/ReactCodeMirror/CustomEditorView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/pgadmin/static/js/components/ReactCodeMirror/CustomEditorView.js b/web/pgadmin/static/js/components/ReactCodeMirror/CustomEditorView.js index 49ed88d5d74..a386044953c 100644 --- a/web/pgadmin/static/js/components/ReactCodeMirror/CustomEditorView.js +++ b/web/pgadmin/static/js/components/ReactCodeMirror/CustomEditorView.js @@ -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) {