From 87e734856bb0b1764b94d4f4f92d118d74ded89d Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Fri, 12 Jan 2018 19:18:41 +0300 Subject: [PATCH] lst: avoid accidental modifications of base content * do not allow to change base content via diff preview --- .../intellij/openapi/vcs/ex/LineStatusTrackerBase.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerBase.kt b/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerBase.kt index bd80ad95a489..61eb15a9e488 100644 --- a/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerBase.kt +++ b/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerBase.kt @@ -61,6 +61,7 @@ abstract class LineStatusTrackerBase { vcsDocument = DocumentImpl(this.document.immutableCharSequence) vcsDocument.putUserData(UndoConstants.DONT_RECORD_UNDO, true) + vcsDocument.setReadOnly(true) documentTracker = DocumentTracker(vcsDocument, this.document) documentTracker.addListener(MyLineTrackerListener()) @@ -123,7 +124,14 @@ abstract class LineStatusTrackerBase { @CalledInAwt protected fun updateDocument(side: Side, commandName: String?, task: (Document) -> Unit): Boolean { val doc = side[vcsDocument, document] - return DiffUtil.executeWriteCommand(doc, project, commandName, { task(doc) }) + + if (side.isLeft) doc.setReadOnly(false) + try { + return DiffUtil.executeWriteCommand(doc, project, commandName, { task(doc) }) + } + finally { + if (side.isLeft) doc.setReadOnly(true) + } } @CalledInAwt