in vsintegration/src/FSharp.LanguageService.Base/ExpansionProvider.cs [129:186]
internal virtual bool HandlePreExec(ref Guid guidCmdGroup, uint nCmdId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) {
if (!this.expansionActive || this.expansionSession == null) {
return false;
}
this.completorActiveDuringPreExec = this.IsCompletorActive(this.view);
if (guidCmdGroup == typeof(VsCommands2K).GUID) {
VsCommands2K cmd = (VsCommands2K)nCmdId;
#if TRACE_EXEC
Trace.WriteLine(String.Format("ExecCommand: {0}", cmd.ToString()));
#endif
switch (cmd) {
case VsCommands2K.CANCEL:
if (this.completorActiveDuringPreExec)
return false;
EndTemplateEditing(true);
return true;
case VsCommands2K.RETURN:
bool leaveCaret = false;
int line = 0, col = 0;
if (NativeMethods.Succeeded(this.view.GetCaretPos(out line, out col))) {
TextSpan span = GetExpansionSpan();
if (!TextSpanHelper.ContainsExclusive(span, line, col)) {
leaveCaret = true;
}
}
if (this.completorActiveDuringPreExec)
return false;
if (this.completorActiveDuringPreExec)
return false;
EndTemplateEditing(leaveCaret);
if (leaveCaret)
return false;
return true;
case VsCommands2K.BACKTAB:
if (this.completorActiveDuringPreExec)
return false;
this.expansionSession.GoToPreviousExpansionField();
return true;
case VsCommands2K.TAB:
if (this.completorActiveDuringPreExec)
return false;
this.expansionSession.GoToNextExpansionField(0); // fCommitIfLast=false
return true;
#if TRACE_EXEC
case VsCommands2K.TYPECHAR:
if (pvaIn != IntPtr.Zero) {
Variant v = Variant.ToVariant(pvaIn);
char ch = v.ToChar();
Trace.WriteLine(String.Format("TYPECHAR: {0}, '{1}', {2}", cmd.ToString(), ch.ToString(), (int)ch));
}
return true;
#endif
}
}
return false;
}