Conversation
Fixed the paste problem when the selection is a single paragraph. In the code a paragraph is indicated by a ‘\n’. Note: This fix is specific to a single paragraph selection. It does not add support for other complex selections.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes paste behavior when the paste target is a single, fully-selected paragraph by avoiding paragraph-level replacement when the replacement text is also a single paragraph.
Changes:
- Added helpers to detect whether the selection spans exactly one complete paragraph and whether the replacement text is exactly one paragraph.
- Trimmed a trailing paragraph marker (
'\n') from replacement text in the special-case scenario to force character replacement.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Src/views/VwSelection.h | Declares new helper methods for single-paragraph detection. |
| Src/views/VwSelection.cpp | Implements helpers and applies newline-trimming logic in ReplaceWithTsString. |
| if (!m_pvpboxEnd && | ||
| targetMin == 0 && | ||
| m_pvpbox->Source()->CStrings() == 1) | ||
| { | ||
| ITsString* firstStr = NULL; | ||
| m_pvpbox->Source()->StringAtIndex(0, &firstStr); | ||
| int firstStrLen = 0; | ||
| CheckHr(firstStr->get_Length(&firstStrLen)); | ||
|
|
||
| if (targetLim == firstStrLen) |
There was a problem hiding this comment.
In the context where this is used, I don't think it is possible for CStrings() to be greater than 1. I was unable to test it greater than 1 so I didn't want to change logic that I couldn't test.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
jasonleenaylor
left a comment
There was a problem hiding this comment.
@jasonleenaylor reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on johnml1135).
|
Please look at branch The new commit is
Why this is needed: the current failure is the ordinary copy-whole-paragraph-over-whole-paragraph case. Keeping the terminal paragraph marker sends a simple replacement into the paragraph-replacement path, which is where the adjacent-paragraph corruption/failure risk shows up. Once the marker is removed, the edit remains a same-paragraph character replacement and continues through the existing Views edit, relayout, commit, and notification code instead of adding a new special replacement path. This deliberately does not try to solve the broader paste problem. Multi-source rendered paragraphs, selections spanning backing properties, interlinear/table/object-run semantics, paragraph-style planning, selection-after-edit behavior, and paste-plan observability should stay in LT-22526. Tests added in Validation from this branch:
This response was created by AI at John's request. |
|
I am fine with the PR as it is, as it makes it better than it was, but to my understanding, the suggestions put in the PR by co-pilot extend it to work with CRLF while the current implementation only handles CR. It also adds a set of tests that could be helpful. |
Fixed the paste problem when the selection is a single paragraph. In the code a paragraph is indicated by a ‘\n’.
Note: This fix is specific to a single paragraph selection. It does not add support for other complex selections.
This change is