fix: honor selected EOL sequence when copying query text to clipboard #10158#10160
Open
hiteshjambhale wants to merge 1 commit into
Open
fix: honor selected EOL sequence when copying query text to clipboard #10158#10160hiteshjambhale wants to merge 1 commit into
hiteshjambhale wants to merge 1 commit into
Conversation
…gadmin-org#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 pgadmin-org#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 pgadmin-org#8691).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough
ChangesSelection EOL handling
Estimated code review effort: 1 (Trivial) | ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #10158 — a regression of the EOL feature added in #7393.
The Query Tool status bar lets you choose LF or CRLF as the end-of-line sequence used when copying query text to the clipboard. Since #8691 this setting had no effect: copied text always used LF regardless of the choice.
Root cause
CustomEditorView.getSelectionFromState()joined the selection ranges with the chosen EOL, but sliced each range usingstate.sliceDoc(from, to)— which always uses the document's own line break (\n). For a normal single-range selection (the common case) there is nothing to join, so every internal line break stayed\nand the LF/CRLF choice was ignored.This was introduced in #8691, where the copy path was reworked to fix multi-cursor copying and switched from
doc.sliceString(..., lineSep)(applies the separator to line breaks) tosliceDoc(...)(does not).Fix
Slice each range with
state.doc.sliceString(range.from, range.to, lineSep)so the chosen EOL is applied to line breaks within the selection as well. The.join(lineSep)still applies it between multiple cursor ranges, so the #8691 multi-cursor fix is preserved.Test steps
pbpaste | xxd | headecho "CR: $(pbpaste | tr -cd '\r' | wc -c) LF: $(pbpaste | tr -cd '\n' | wc -c)"0d 0a(CRLF) — CR and LF counts are equal and non-zero.0a(LF) — CR count is0.Summary by CodeRabbit