diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/CopyResultsRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/CopyResultsRequest.cs index f89a5825..d1e45d64 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/CopyResultsRequest.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/CopyResultsRequest.cs @@ -27,6 +27,11 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts /// public bool RemoveNewLines { get; set; } + /// + /// Whether to avoid adding a line break between rows during row concatenation for copying result when the previous row already has a trailing line break. + /// + public bool AvoidNewLineAfterTailingLineBreak { get; set; } + /// /// Whether to include the column headers. /// diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs index 594cdac4..0fc91726 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs @@ -789,7 +789,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution } } // Add line break if this is not the last row in all selections. - if (rowIndex + pageStartRowIndex != lastRowIndex) + if (rowIndex + pageStartRowIndex != lastRowIndex && (!builder.ToString().EndsWith(Environment.NewLine) || !requestParams.AvoidNewLineAfterTailingLineBreak)) { builder.Append(Environment.NewLine); }