mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Use config instead of parameter for query editor result copy and fix some wording (#2124)
* Fix typo and update wording * use config instead of parameter for copying result
This commit is contained in:
@@ -22,21 +22,6 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
|
||||
/// </summary>
|
||||
public class CopyResultsRequestParams : SubsetParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether to remove the line break from cell values.
|
||||
/// </summary>
|
||||
public bool RemoveNewLines { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public bool AvoidNewLineAfterTailingLineBreak { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to include the column headers.
|
||||
/// </summary>
|
||||
public bool IncludeHeaders { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The selections.
|
||||
/// </summary>
|
||||
|
||||
@@ -729,7 +729,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
var lastRowIndex = rowRanges.Last().End;
|
||||
var builder = new StringBuilder();
|
||||
var pageSize = 200;
|
||||
if (requestParams.IncludeHeaders)
|
||||
if (Settings.QueryEditorSettings.Results.CopyIncludeHeaders)
|
||||
{
|
||||
Validate.IsNotNullOrEmptyString(nameof(requestParams.OwnerUri), requestParams.OwnerUri);
|
||||
Query query;
|
||||
@@ -780,7 +780,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
selection.FromColumn <= columnIndex &&
|
||||
selection.ToColumn >= columnIndex))
|
||||
{
|
||||
builder.Append(requestParams.RemoveNewLines ? row[columnIndex].DisplayValue.ReplaceLineEndings(" ") : row[columnIndex].DisplayValue);
|
||||
builder.Append(Settings.QueryEditorSettings.Results.CopyRemoveNewLine ? row[columnIndex].DisplayValue.ReplaceLineEndings(" ") : row[columnIndex].DisplayValue);
|
||||
}
|
||||
if (columnIndex != lastColumnIndex)
|
||||
{
|
||||
@@ -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 && (!builder.ToString().EndsWith(Environment.NewLine) || !requestParams.AvoidNewLineAfterTailingLineBreak))
|
||||
if (rowIndex + pageStartRowIndex != lastRowIndex && (!builder.ToString().EndsWith(Environment.NewLine) || !Settings.QueryEditorSettings.Results.SkipNewLineAfterTrailingLineBreak))
|
||||
{
|
||||
builder.Append(Environment.NewLine);
|
||||
}
|
||||
@@ -1141,6 +1141,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
internal Task UpdateSettings(SqlToolsSettings newSettings, SqlToolsSettings oldSettings, EventContext eventContext)
|
||||
{
|
||||
Settings.QueryExecutionSettings.Update(newSettings.QueryExecutionSettings);
|
||||
Settings.QueryEditorSettings.Update(newSettings.QueryEditorSettings);
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
{
|
||||
public class QueryEditorResultSettingsValues
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether to remove the line break from cell values when copying results.
|
||||
/// </summary>
|
||||
public bool CopyRemoveNewLine { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to skip adding a line break between rows when copying results when the previous row already has a trailing line break.
|
||||
/// </summary>
|
||||
public bool SkipNewLineAfterTrailingLineBreak { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to include the column headers when copying results.
|
||||
/// </summary>
|
||||
public bool CopyIncludeHeaders { get; set; } = false;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
{
|
||||
public class QueryEditorSettingsValues
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the results setting
|
||||
/// </summary>
|
||||
[JsonProperty("results")]
|
||||
public QueryEditorResultSettingsValues? Results { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Update the current settings with the new settings
|
||||
/// </summary>
|
||||
/// <param name="newSettings">The new settings</param>
|
||||
public void Update(QueryEditorSettingsValues newSettings)
|
||||
{
|
||||
if (newSettings != null)
|
||||
{
|
||||
Results = newSettings.Results ?? Results;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
private SqlToolsSettingsValues mssqlTools = null;
|
||||
private SqlToolsSettingsValues allSqlTools = null;
|
||||
private TelemetrySettingsValues telemetrySettings = null;
|
||||
private QueryEditorSettingsValues queryEditorSettings = null;
|
||||
|
||||
public ISqlToolsSettingsValues SqlTools
|
||||
{
|
||||
@@ -83,6 +84,23 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the underlying query editor settings value object
|
||||
/// </summary>
|
||||
[JsonProperty("queryEditor")]
|
||||
public QueryEditorSettingsValues QueryEditorSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
this.queryEditorSettings ??= new QueryEditorSettingsValues();
|
||||
return this.queryEditorSettings;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.queryEditorSettings = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query execution settings forwarding property
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user