diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.cs index a7d24f00b3..862f94506e 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.cs @@ -107,6 +107,61 @@ namespace ICSharpCode.SharpDevelop.Gui } else if (e.Key == Key.PageDown) { e.Handled = true; ChangeIndex((int)Math.Round(+listBox.ActualHeight / 20)); + } else if (e.Key == Key.Tab) { + e.Handled = true; + CompleteSelectedEntry(); + } + } + + private void CompleteSelectedEntry() + { + if (listBox.SelectedItem == null) { + return; + } + + string completed = null; + bool partlyComplete = false; + + object tag = ((GotoEntry) listBox.SelectedItem).Tag; + if (tag is IUnresolvedEntity) { + IUnresolvedEntity c = tag as IUnresolvedEntity; + completed = c.Name; + partlyComplete = (tag is IUnresolvedMember); + } else if (tag is IEntity) { + IEntity m = tag as IEntity; + completed = m.Name; + partlyComplete = (tag is IMember); + } else if (tag is FileLineReference) { + FileLineReference flref = tag as FileLineReference; + // Only complete if we are not matching with a concrete number + if (flref.Line == 0) { + completed = Path.GetFileName(flref.FileName); + } else { + return; + } + } else { + // Unsupported list item, do nothing + return; + } + + if (completed != null) { + string currentText = textBox.Text; + int dotPos = currentText.IndexOf('.'); + string needle = currentText; + string member = null; + if (dotPos > 0) { + needle = currentText.Substring(0, dotPos).Trim(); + member = currentText.Substring(dotPos + 1).Trim(); + } + + // Replace the text, set caret to end, so user can continue typing + if (partlyComplete && (member != null)) { + // Only replace the part after the dot + textBox.Text = needle + "." + completed; + } else { + textBox.Text = completed; + } + textBox.CaretIndex = textBox.Text.Length; } } @@ -133,6 +188,15 @@ namespace ICSharpCode.SharpDevelop.Gui if (text.Length == 1 && !char.IsDigit(text, 0)) { return; } + + int dotPos = text.IndexOf('.'); + string needle = text; + string member = null; + if (dotPos > 0) { + needle = text.Substring(0, dotPos).Trim(); + member = text.Substring(dotPos + 1).Trim(); + } + int commaPos = text.IndexOf(','); if (commaPos < 0) { // use "File, ##" or "File: ##" syntax for line numbers @@ -154,8 +218,12 @@ namespace ICSharpCode.SharpDevelop.Gui AddSourceFiles(file, lineNr); } else { AddSourceFiles(text, 0); - foreach (IUnresolvedTypeDefinition c in SearchClasses(text)) { - AddItem(c, GetMatchType(text, c.Name), false); + foreach (IUnresolvedTypeDefinition c in SearchClasses(needle)) { + if (!String.IsNullOrEmpty(member)) { + AddAllMembersMatchingText(c, member, false); + } else { + AddItem(c, GetMatchType(needle, c.Name), false); + } } AddAllMembersMatchingText(text); } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.xaml b/src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.xaml index 20b99d0948..7ba7bd9ce4 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.xaml +++ b/src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.xaml @@ -15,6 +15,11 @@ + + @@ -46,7 +51,7 @@ - +