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.
Contributor
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. |
| targetMin == 0 && | ||
| m_pvpbox->Source()->CStrings() == 1) | ||
| { | ||
| ITsString* firstStr = NULL; |
Comment on lines
+5435
to
+5444
| 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) |
Comment on lines
+5466
to
+5483
| CheckHr(replacementTstr->get_Text(&replacementBstr)); | ||
| const wchar* replacementText = replacementBstr.Chars(); | ||
| for (int ii = 0; ii < replacementCharCount; ii++) | ||
| { | ||
| if (replacementText[ii] == '\n') | ||
| { | ||
| // The last character is a '\n' and there are no other '\n' characters in the string. | ||
| if (ii == replacementCharCount - 1) | ||
| { | ||
| return true; | ||
| } | ||
| else | ||
| { | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| return false; |
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.
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