Skip to content

Commit

Permalink
fix #813 #823
Browse files Browse the repository at this point in the history
  • Loading branch information
bao-qian committed Jul 20, 2016
1 parent 24b9025 commit a72cdce
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
6 changes: 5 additions & 1 deletion Wox/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ private void OnKeyDown(object sender, KeyEventArgs e)

private void OnTextChanged(object sender, TextChangedEventArgs e)
{
QueryTextBox.CaretIndex = QueryTextBox.Text.Length;
if (_viewModel.QueryTextCursorMovedToEnd)
{
QueryTextBox.CaretIndex = QueryTextBox.Text.Length;
_viewModel.QueryTextCursorMovedToEnd = false;
}
}
}
}
4 changes: 2 additions & 2 deletions Wox/PublicAPIInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public PublicAPIInstance(SettingWindowViewModel settingsVM, MainViewModel mainVM

public void ChangeQuery(string query, bool requery = false)
{
_mainVM.QueryText = query;
_mainVM.ChangeQueryText(query);
}

public void ChangeQueryText(string query, bool selectAll = false)
{
_mainVM.QueryText = query;
_mainVM.ChangeQueryText(query);
}

[Obsolete]
Expand Down
18 changes: 15 additions & 3 deletions Wox/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,19 @@ public string QueryText
Query();
}
}

/// <summary>
/// we need move cursor to end when we manually changed query
/// but we don't want to move cursor to end when query is updated from TextBox
/// </summary>
/// <param name="queryText"></param>
public void ChangeQueryText(string queryText)
{
QueryTextCursorMovedToEnd = true;
QueryText = queryText;
}
public bool QueryTextSelected { get; set; }
public bool QueryTextCursorMovedToEnd { get; set; }

private ResultsViewModel _selectedResults;
private ResultsViewModel SelectedResults
Expand All @@ -218,7 +230,7 @@ private ResultsViewModel SelectedResults
{
ContextMenu.Visbility = Visibility.Collapsed;
History.Visbility = Visibility.Collapsed;
QueryText = _queryTextBeforeLeaveResults;
ChangeQueryText(_queryTextBeforeLeaveResults);
}
else
{
Expand Down Expand Up @@ -325,7 +337,7 @@ private void QueryHistory()
Action = _ =>
{
SelectedResults = Results;
QueryText = h.Query;
ChangeQueryText(h.Query);
return false;
}
};
Expand Down Expand Up @@ -547,7 +559,7 @@ private void SetCustomPluginHotkey()
{
if (ShouldIgnoreHotkeys()) return;
MainWindowVisibility = Visibility.Visible;
QueryText = hotkey.ActionKeyword;
ChangeQueryText(hotkey.ActionKeyword);
});
}
}
Expand Down

0 comments on commit a72cdce

Please sign in to comment.