mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-08-17 16:34:44 -05:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user