Browse Source

Fixed build.

Expand snippets only when Tab is pressed.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5070 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
d7cd0e58f7
  1. 10
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/SnippetCompletionItem.cs
  2. 34
      src/Main/Base/Project/Src/Commands/CustomStringTagProvider.cs

10
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/SnippetCompletionItem.cs

@ -61,8 +61,14 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets
{ {
if (context.Editor != this.textEditor) if (context.Editor != this.textEditor)
throw new ArgumentException("wrong editor"); throw new ArgumentException("wrong editor");
context.Editor.Document.Remove(context.StartOffset, context.Length); using (context.Editor.Document.OpenUndoGroup()) {
CreateSnippet().Insert(textArea); if (context.CompletionChar == '\t') {
context.Editor.Document.Remove(context.StartOffset, context.Length);
CreateSnippet().Insert(textArea);
} else {
context.Editor.Document.Replace(context.StartOffset, context.Length, this.Text);
}
}
} }
Snippet CreateSnippet() Snippet CreateSnippet()

34
src/Main/Base/Project/Src/Commands/CustomStringTagProvider.cs

@ -58,43 +58,42 @@ namespace ICSharpCode.SharpDevelop.Commands
return "<no current project>"; return "<no current project>";
else else
return ProjectService.CurrentProject.Name; return ProjectService.CurrentProject.Name;
} }
switch (tag.ToUpperInvariant()) { switch (tag.ToUpperInvariant()) {
case "ITEMPATH": case "ITEMPATH":
try { try {
return GetCurrentItemPath() ?? string.Empty; return GetCurrentItemPath() ?? string.Empty;
} catch (Exception) {} } catch (Exception) {}
break; return string.Empty;
case "ITEMDIR": case "ITEMDIR":
try { try {
return Path.GetDirectoryName(GetCurrentItemPath()) ?? string.Empty; return Path.GetDirectoryName(GetCurrentItemPath()) ?? string.Empty;
} catch (Exception) {} } catch (Exception) {}
break; return string.Empty;
case "ITEMFILENAME": case "ITEMFILENAME":
try { try {
return Path.GetFileName(GetCurrentItemPath()) ?? string.Empty; return Path.GetFileName(GetCurrentItemPath()) ?? string.Empty;
} catch (Exception) {} } catch (Exception) {}
break; return string.Empty;
case "ITEMEXT": case "ITEMEXT":
try { try {
return Path.GetExtension(GetCurrentItemPath()) ?? string.Empty; return Path.GetExtension(GetCurrentItemPath()) ?? string.Empty;
} catch (Exception) {} } catch (Exception) {}
break; return string.Empty;
case "CURLINE": case "CURLINE":
{ {
IPositionable positionable = WorkbenchSingleton.Workbench.ActiveViewContent as IPositionable; IPositionable positionable = WorkbenchSingleton.Workbench.ActiveViewContent as IPositionable;
if (positionable != null) if (positionable != null)
return positionable.Line.ToString(); return positionable.Line.ToString();
break; return string.Empty;
} }
case "CURCOL": case "CURCOL":
{ {
IPositionable positionable = WorkbenchSingleton.Workbench.ActiveViewContent as IPositionable; IPositionable positionable = WorkbenchSingleton.Workbench.ActiveViewContent as IPositionable;
if (positionable != null) if (positionable != null)
return positionable.Column.ToString(); return positionable.Column.ToString();
break; return string.Empty;
} }
case "CURTEXT": case "CURTEXT":
{ {
@ -102,42 +101,40 @@ namespace ICSharpCode.SharpDevelop.Commands
if (tecp != null) { if (tecp != null) {
return tecp.TextEditor.SelectedText; return tecp.TextEditor.SelectedText;
} }
break; return string.Empty;
} }
case "TARGETPATH": case "TARGETPATH":
try { try {
return GetCurrentTargetPath() ?? string.Empty; return GetCurrentTargetPath() ?? string.Empty;
} catch (Exception) {} } catch (Exception) {}
break; return string.Empty;
case "TARGETDIR": case "TARGETDIR":
try { try {
return Path.GetDirectoryName(GetCurrentTargetPath()) ?? string.Empty; return Path.GetDirectoryName(GetCurrentTargetPath()) ?? string.Empty;
} catch (Exception) {} } catch (Exception) {}
break; return string.Empty;
case "TARGETNAME": case "TARGETNAME":
try { try {
return Path.GetFileName(GetCurrentTargetPath()) ?? string.Empty; return Path.GetFileName(GetCurrentTargetPath()) ?? string.Empty;
} catch (Exception) {} } catch (Exception) {}
break; return string.Empty;
case "TARGETEXT": case "TARGETEXT":
try { try {
return Path.GetExtension(GetCurrentTargetPath()) ?? string.Empty; return Path.GetExtension(GetCurrentTargetPath()) ?? string.Empty;
} catch (Exception) {} } catch (Exception) {}
break; return string.Empty;
case "PROJECTDIR": case "PROJECTDIR":
if (ProjectService.CurrentProject != null) { if (ProjectService.CurrentProject != null) {
return ProjectService.CurrentProject.Directory; return ProjectService.CurrentProject.Directory;
} }
break; return string.Empty;
case "PROJECTFILENAME": case "PROJECTFILENAME":
if (ProjectService.CurrentProject != null) { if (ProjectService.CurrentProject != null) {
try { try {
return Path.GetFileName(ProjectService.CurrentProject.FileName); return Path.GetFileName(ProjectService.CurrentProject.FileName);
} catch (Exception) {} } catch (Exception) {}
} }
break; return string.Empty;
case "COMBINEDIR": case "COMBINEDIR":
case "SOLUTIONDIR": case "SOLUTIONDIR":
return Path.GetDirectoryName(ProjectService.OpenSolution.FileName); return Path.GetDirectoryName(ProjectService.OpenSolution.FileName);
@ -146,13 +143,14 @@ namespace ICSharpCode.SharpDevelop.Commands
try { try {
return Path.GetFileName(ProjectService.OpenSolution.FileName); return Path.GetFileName(ProjectService.OpenSolution.FileName);
} catch (Exception) {} } catch (Exception) {}
break; return string.Empty;
case "SHARPDEVELOPBINPATH": case "SHARPDEVELOPBINPATH":
return Path.GetDirectoryName(typeof(SharpDevelopStringTagProvider).Assembly.Location); return Path.GetDirectoryName(typeof(SharpDevelopStringTagProvider).Assembly.Location);
case "STARTUPPATH": case "STARTUPPATH":
return Application.StartupPath; return Application.StartupPath;
default:
return null;
} }
return null;
} }
} }

Loading…
Cancel
Save