Skip to content

LT-20857: Fixed a paste problem#900

Open
mark-sil wants to merge 1 commit into
mainfrom
LT-20857a
Open

LT-20857: Fixed a paste problem#900
mark-sil wants to merge 1 commit into
mainfrom
LT-20857a

Conversation

@mark-sil
Copy link
Copy Markdown
Contributor

@mark-sil mark-sil commented May 20, 2026

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 Reviewable

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.
@github-actions
Copy link
Copy Markdown

NUnit Tests

    1 files  ±0      1 suites  ±0   11m 12s ⏱️ +35s
4 205 tests ±0  4 134 ✅ ±0  71 💤 ±0  0 ❌ ±0 
4 214 runs  ±0  4 143 ✅ ±0  71 💤 ±0  0 ❌ ±0 

Results for commit 1ef5959. ± Comparison against base commit 272325a.

@johnml1135 johnml1135 requested review from Copilot and johnml1135 May 20, 2026 23:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Src/views/VwSelection.cpp
targetMin == 0 &&
m_pvpbox->Source()->CStrings() == 1)
{
ITsString* firstStr = NULL;
Comment thread Src/views/VwSelection.cpp
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 thread Src/views/VwSelection.cpp
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants