diff --git a/src/EditorFeatures/VisualBasic/LineCommit/CommitCommandHandler.vb b/src/EditorFeatures/VisualBasic/LineCommit/CommitCommandHandler.vb index 3734db9261b6c03e24eb4d1be5b380f153f89a24..12239f648251ad5494ff3011f5f92b87a791add1 100644 --- a/src/EditorFeatures/VisualBasic/LineCommit/CommitCommandHandler.vb +++ b/src/EditorFeatures/VisualBasic/LineCommit/CommitCommandHandler.vb @@ -246,7 +246,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.LineCommit ' Did we paste content that changed the number of lines? If oldVersion.Changes IsNot Nothing AndAlso oldVersion.Changes.IncludesLineChanges Then Try - _bufferManagerFactory.CreateForBuffer(args.SubjectBuffer).CommitDirty(isExplicitFormat:=True, cancellationToken:=waitContext.CancellationToken) + _bufferManagerFactory.CreateForBuffer(args.SubjectBuffer).CommitDirty(isExplicitFormat:=False, cancellationToken:=waitContext.CancellationToken) Catch ex As OperationCanceledException ' If the commit was cancelled, we still want the paste to go through End Try @@ -268,7 +268,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.LineCommit allowCancel:=True, action:=Sub(waitContext) Using transaction = _textUndoHistoryRegistry.GetHistory(args.TextView.TextBuffer).CreateTransaction(VBEditorResources.FormatOnSave) - _bufferManagerFactory.CreateForBuffer(args.SubjectBuffer).CommitDirty(isExplicitFormat:=True, cancellationToken:=waitContext.CancellationToken) + _bufferManagerFactory.CreateForBuffer(args.SubjectBuffer).CommitDirty(isExplicitFormat:=False, cancellationToken:=waitContext.CancellationToken) ' We should only create the transaction if anything actually happened If transaction.UndoPrimitives.Any() Then diff --git a/src/EditorFeatures/VisualBasic/LineCommit/CommitViewManager.vb b/src/EditorFeatures/VisualBasic/LineCommit/CommitViewManager.vb index 1b199a5ee1f715c0402e7718438713e693d61271..f8effddb47fc22dcde3ce0e921d701ae3fa1ba7e 100644 --- a/src/EditorFeatures/VisualBasic/LineCommit/CommitViewManager.vb +++ b/src/EditorFeatures/VisualBasic/LineCommit/CommitViewManager.vb @@ -117,7 +117,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.LineCommit action:= Sub(waitContext) For Each buffer In _view.BufferGraph.GetTextBuffers(Function(b) b.ContentType.IsOfType(ContentTypeNames.VisualBasicContentType)) - _commitBufferManagerFactory.CreateForBuffer(buffer).CommitDirty(isExplicitFormat:=True, cancellationToken:=waitContext.CancellationToken) + _commitBufferManagerFactory.CreateForBuffer(buffer).CommitDirty(isExplicitFormat:=False, cancellationToken:=waitContext.CancellationToken) Next End Sub) End Sub diff --git a/src/EditorFeatures/VisualBasicTest/LineCommit/CommitOnMiscellaneousCommandsTests.vb b/src/EditorFeatures/VisualBasicTest/LineCommit/CommitOnMiscellaneousCommandsTests.vb index 0cdafed6e9dc16dd621a0aaac8bc2fda62c0a506..7f7e4a2469699541a94f365f754bf694d3f382f7 100644 --- a/src/EditorFeatures/VisualBasicTest/LineCommit/CommitOnMiscellaneousCommandsTests.vb +++ b/src/EditorFeatures/VisualBasicTest/LineCommit/CommitOnMiscellaneousCommandsTests.vb @@ -22,6 +22,22 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.LineCommit End Using End Sub + + + + Public Sub DontCommitOnMultiLinePasteWithPrettyListingOff() + Using testData = New CommitTestData( + + $$ + + + ) + testData.Workspace.Options = testData.Workspace.Options.WithChangedOption(FeatureOnOffOptions.PrettyListing, LanguageNames.VisualBasic, False) + testData.CommandHandler.ExecuteCommand(New PasteCommandArgs(testData.View, testData.Buffer), Sub() testData.EditorOperations.InsertText("Class Program" & vbCrLf & " Sub M(abc As Integer)" & vbCrLf & " Dim a = 7" & vbCrLf & " End Sub" & vbCrLf & "End Class")) + Assert.Equal(" Dim a = 7", testData.Buffer.CurrentSnapshot.GetLineFromLineNumber(2).GetText()) + End Using + End Sub + @@ -54,6 +70,27 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.LineCommit End Using End Sub + + + Public Sub DontCommitOnSavePrettyListingOff() + Using testData = New CommitTestData( + + +Class Program + Sub M(abc As Integer) + Dim a $$= 7 + End Sub +End Class + + + ) + testData.Workspace.Options = testData.Workspace.Options.WithChangedOption(FeatureOnOffOptions.PrettyListing, LanguageNames.VisualBasic, False) + testData.Buffer.Insert(57, " ") + testData.CommandHandler.ExecuteCommand(New SaveCommandArgs(testData.View, testData.Buffer), Sub() Exit Sub) + Assert.Equal(" Dim a = 7", testData.Buffer.CurrentSnapshot.GetLineFromLineNumber(3).GetText()) + End Using + End Sub +