Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@kenherring
Copy link
Contributor

@kenherring kenherring commented Jul 4, 2025

Resolves #151902

Summary

This PR aims to fix a bug that appears to have been introduced with #230129. The function called on the next line was moved but the if statement to check for it's existence on the object was not updated. It does not appear that the line within the if statement would ever be reached.

Test Case

  1. Open a terminal and open the FindWidget with ctrl+f
  2. Search for some text that exists in the terminal, such as "some text". The text "some text" is copied to the clipboard
  3. Focus away from the terminal and copy some "other text" to the clipboard
  4. Focus back on the terminal.
  5. Use ctrl+f to focus on the find widget.
  6. Paste the copied text.
    • Expect: "other text"
    • Get: "some text"

In testing I found that the clipboard is overwritten in step #4. It appears that the terminal fires a onSelectionChanged even though there is no change to the selection.

@kenherring
Copy link
Contributor Author

Want to note that the copyOnSelection event seems overly aggressive. Here is another test case which seems to be problematic, though it doesn't have a clear causation or solution.

I will attempt to provide a solution for this under a separate PR. Figured it might be worth including here too as someone reviewing the PR might have some insight.

  1. Open a terminal and open the FindWidget with ctrl+f
  2. Search for some text that exists in the terminal, such as "some text". The text "some text" is copied to the clipboard
  3. Focus away from the terminal and copy some "other text" to the clipboard
  4. Focus back on the terminal.
  5. Press any key to enter a character into the terminal.
    • Alternatively use ctrl+f to paste into the terminal.
  6. Use ctrl+f to paste into the terminal. The searched text copied to the clipboard in step 2 is pasted.
    • Expect: "other text"
    • Get: "some text"

It appears the rendering done as a result of step 5 includes calling the onSelectionChanged event which overwrites the clipboard unexpectedly.

@kenherring
Copy link
Contributor Author

Is there anything I can/need to do to get movement on this?

@Tyriar Tyriar assigned anthonykim1 and unassigned Tyriar and meganrogge Aug 5, 2025
@Tyriar Tyriar added this to the August 2025 milestone Aug 5, 2025
@anthonykim1
Copy link
Contributor

Hi @kenherring Thanks much for looking into this!

I'm not quite getting the difference between the first test case in this PR vs. the second test case.

Is the difference just that you are doing Press any key to enter a character into the terminal. instead of straight up doing ctrl+f in one of the steps?

@kenherring
Copy link
Contributor Author

@anthonykim1 You are correct. The first test case, which is resolved by this PR, involves using ctrl+f to open or access the find widget. This overwrites the clipboard.

The second test case is not addressed by this PR and involves entering any key to add text to the terminal, which overwrites the clipboard when the added text causes a redrawing of the terminal. This does not have as clear of a solution and is something I'll be willing to dig deeper on in a future PR.

@anthonykim1
Copy link
Contributor

anthonykim1 commented Aug 12, 2025

Make sense, @kenherring Yeah, I think we should address that(the case you just mentioned) as well?? unless its expected behavior @Tyriar

It seems like what is happening with that second case (after 'copying from clipboard'), and typing in terminal is that those selection triggered from the previous ctrl+f gets selected again and shows the blinks as well.

@anthonykim1
Copy link
Contributor

anthonykim1 commented Aug 12, 2025

This PR is still improvement as it prevents terminal find from overwriting more recent copy and paste from the editor when ctrl+f is triggered right away after clipboard from editor.

Before this PR:

focusBug.mov

After this PR:

fixedFocus.mov

@anthonykim1 anthonykim1 requested a review from Tyriar August 12, 2025 16:07
@anthonykim1 anthonykim1 merged commit 610e0da into microsoft:main Aug 13, 2025
17 checks passed
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Sep 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminal: Copy on selection + new highlight in 1.68 copies previous term on CMD+F

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.