Skip to content

Commit

Permalink
Fixes #486 Define Measure not using Separator specified in Options
Browse files Browse the repository at this point in the history
  • Loading branch information
dgosbell committed Dec 21, 2020
1 parent 57e3bd9 commit aa965e0
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/DaxStudio.UI/ViewModels/DocumentViewModel.cs
Expand Up @@ -1381,9 +1381,13 @@ public async Task<DataTable> ExecuteDataTableQueryAsync(string daxQuery)
_timer.Start();
_queryStopWatch = new Stopwatch();
_queryStopWatch.Start();
var dt = c.ExecuteDaxQueryDataTable(daxQuery);
dt.FixColumnNaming(daxQuery);
return dt;
DataTable dt;
return await Task.Run(() => {
dt = c.ExecuteDaxQueryDataTable(daxQuery);
dt.FixColumnNaming(daxQuery);
return dt;
});

}
catch (Exception e)
{
Expand Down Expand Up @@ -1944,6 +1948,14 @@ private void DefineMeasureOnEditor(string measureName, string measureExpression)

var currentText = editor.Text;

// if the default separator is not the default Comma style
// then we should switch the separators to the SemiColon style
if (Options.DefaultSeparator == DelimiterType.SemiColon)
{
var dsm = new DelimiterStateMachine(DelimiterType.SemiColon);
measureExpression = dsm.ProcessString(measureExpression);
}

var measureDeclaration = $"MEASURE {measureName} = {measureExpression}";
// TODO - expand measure expression and generate other measures here!!

Expand Down Expand Up @@ -3720,11 +3732,14 @@ internal void AppendText(string paramXml)

}

void IDropTarget.DragOver(IDropInfo dropInfo)
public void DragOver(IDropInfo dropInfo)
{
IntellisenseProvider?.CloseCompletionWindow();

if (dropInfo.DragInfo.DataObject is IADOTabularObject || dropInfo.DragInfo.Data is string)
DataObject data = dropInfo.Data as DataObject;
bool stringPresent = data?.GetDataPresent(DataFormats.StringFormat)??false;

if (dropInfo.DragInfo?.DataObject is IADOTabularObject || stringPresent)
{
dropInfo.Effects = DragDropEffects.Move;
var pt = dropInfo.DropPosition;
Expand All @@ -3740,18 +3755,21 @@ void IDropTarget.DragOver(IDropInfo dropInfo)
}
}

void IDropTarget.Drop(IDropInfo dropInfo)
public void Drop(IDropInfo dropInfo)
{
var obj = dropInfo.DragInfo.DataObject as IADOTabularObject;
var obj = dropInfo.DragInfo?.DataObject as IADOTabularObject;
var text = string.Empty;
if (obj != null)
{
text = obj.DaxName;
}

if (dropInfo.DragInfo.Data is string)
DataObject data = dropInfo.Data as DataObject;
bool stringPresent = data?.GetDataPresent(DataFormats.StringFormat) ?? false;

if (stringPresent)
{
text = dropInfo.DragInfo.Data as string;
text = data.GetText();
}
InsertTextAtCaret(text);
}
Expand Down

0 comments on commit aa965e0

Please sign in to comment.