From 6f8350fd7a366db6bdcb4759666bc7f3065cb99d Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Tue, 26 Sep 2023 11:33:54 +0200 Subject: [PATCH] vcs: add success indication to 'Copy to Clipboard' action for non-applied ranges Follow-up: ab279348262476a59ce85f429cb0f5f149697cc7 GitOrigin-RevId: a8b3ec079f6fc286be98cf5076ed9960c61cfc3d --- platform/diff-api/resources/messages/DiffBundle.properties | 1 + .../openapi/vcs/changes/patch/tool/ApplyPatchViewer.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/platform/diff-api/resources/messages/DiffBundle.properties b/platform/diff-api/resources/messages/DiffBundle.properties index b47d5462f3b4..ef9bca973dfa 100644 --- a/platform/diff-api/resources/messages/DiffBundle.properties +++ b/platform/diff-api/resources/messages/DiffBundle.properties @@ -59,6 +59,7 @@ merge.dialog.ignore.change.command=Ignore change merge.dialog.resolve.conflict.command=Resolve conflict merge.dialog.apply.non.conflicted.changes.command=Apply non conflicted changes patch.dialog.copy.change.command=Copy to clipboard +patch.dialog.copy.change.command.balloon=Copied to clipboard # suppress inspection "UnusedProperty": used by 3-party plugins merge.dialog.exit.without.applying.changes.confirmation.message=Are you sure you want to exit without applying changes? cancel.visual.merge.dialog.title=Cancel File Merge diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/tool/ApplyPatchViewer.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/tool/ApplyPatchViewer.java index 6ad216e41098..401e8587bb93 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/tool/ApplyPatchViewer.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/tool/ApplyPatchViewer.java @@ -1,6 +1,7 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.vcs.changes.patch.tool; +import com.intellij.codeInsight.hint.HintManager; import com.intellij.diff.*; import com.intellij.diff.actions.ProxyUndoRedoAction; import com.intellij.diff.actions.impl.FocusOppositePaneAction; @@ -451,6 +452,9 @@ class ApplyPatchViewer implements DataProvider, Disposable { CharSequence newContent = DiffUtil.getLinesContent(myPatchEditor.getDocument(), patchRange.start, patchRange.end); CopyPasteManager.copyTextToClipboard(newContent.toString()); + + myPatchEditor.getCaretModel().moveToOffset(myPatchEditor.getDocument().getLineStartOffset(patchRange.start)); + HintManager.getInstance().showInformationHint(myPatchEditor, DiffBundle.message("patch.dialog.copy.change.command.balloon"), HintManager.UNDER); } private final class ApplySelectedChangesAction extends ApplySelectedChangesActionBase {