1

Topic: VS 2019 <Esc> does not exit insert mode in HTML files - causes error

Hi Jon - sorry, I know escape handling is your favorite topic.  smile

I've been seeing this error ever since I moved to VS2019 (16.8.4).

I'm on version 3.11 of viemu.

Escape does not work to leave insert mode in html files and causes the following error(s) in VS. FYI, I don't have any of the typical extensions that affect this sort of thing (resharper, intellisense extensions, etc). Just naked VS.

Esc works fine in all other file types that I've tried.

By the way, I've noticed that it works correctly if you have any text selected. At that point, the 'SelectionCancel' behavior seems to kick in and it works.

I've tried mapping something to '<S-Up> <esc', but the Shift-up (to select some text) doesn't work.

Thanks!

https://i.ibb.co/zsRhh1T/Capture.jpg

  <entry>
    <record>2871</record>
    <time>2021/02/28 17:29:41.089</time>
    <type>Information</type>
    <source>Web Editor</source>
    <description>System.Runtime.InteropServices.InvalidOleVariantTypeException: Specified OLE variant is invalid.&#x000D;&#x000A;   at System.Runtime.InteropServices.Marshal.GetObjectForNativeVariant(IntPtr pSrcNativeVariant)&#x000D;&#x000A;   at Microsoft.VisualStudio.Html.Interop.CommandTargetToOleShim.TranslateInputArg(Guid&amp; guidCommandGroup, UInt32 commandID, IntPtr variantIn)&#x000D;&#x000A;   at Microsoft.VisualStudio.Html.Interop.CommandTargetToOleShim.Exec(Guid&amp; guidCommandGroup, UInt32 commandID, UInt32 commandExecOpt, IntPtr variantIn, IntPtr variantOut)</description>
  </entry>
  <entry>
    <record>2872</record>
    <time>2021/02/28 17:29:41.114</time>
    <type>Information</type>
    <source>Web Editor</source>
    <description>System.Runtime.InteropServices.InvalidOleVariantTypeException: Specified OLE variant is invalid.&#x000D;&#x000A;   at System.Runtime.InteropServices.Marshal.GetObjectForNativeVariant(IntPtr pSrcNativeVariant)&#x000D;&#x000A;   at Microsoft.VisualStudio.Html.Interop.CommandTargetToOleShim.TranslateInputArg(Guid&amp; guidCommandGroup, UInt32 commandID, IntPtr variantIn)&#x000D;&#x000A;   at Microsoft.VisualStudio.Html.Interop.CommandTargetToOleShim.Exec(Guid&amp; guidCommandGroup, UInt32 commandID, UInt32 commandExecOpt, IntPtr variantIn, IntPtr variantOut)</description>
  </entry>
  <entry>
    <record>2873</record>
    <time>2021/02/28 17:29:41.525</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.Runtime.InteropServices.InvalidOleVariantTypeException: Specified OLE variant is invalid.&#x000D;&#x000A;   at System.Runtime.InteropServices.Marshal.GetObjectForNativeVariant(IntPtr pSrcNativeVariant)&#x000D;&#x000A;   at Microsoft.VisualStudio.Html.Interop.CommandTargetToOleShim.TranslateInputArg(Guid&amp; guidCommandGroup, UInt32 commandID, IntPtr variantIn)&#x000D;&#x000A;   at Microsoft.VisualStudio.Html.Interop.CommandTargetToOleShim.Exec(Guid&amp; guidCommandGroup, UInt32 commandID, UInt32 commandExecOpt, IntPtr variantIn, IntPtr variantOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.CommandHandlerServiceAdapter.&lt;&gt;c__DisplayClass18_0.&lt;Exec&gt;g__executeNextCommandTarget|1()&#x000D;&#x000A;   at Microsoft.VisualStudio.UI.Text.Commanding.Implementation.EditorCommandHandlerService.ExecuteStartingAtIndex[T](Func`3 argsFactory, FrugalList`1 buffersAndHandlers, Int32 startIndex, EditorCommandHandlerServiceState state, Action nextCommandHandler)&#x000D;&#x000A;   at Microsoft.VisualStudio.UI.Text.Commanding.Implementation.EditorCommandHandlerService.&lt;&gt;c__DisplayClass14_0`1.&lt;ExecuteStartingAtIndex&gt;b__2()&#x000D;&#x000A;   at Microsoft.WebTools.Languages.Shared.Editor.Completion.TypingCommandHandler.ExecuteChainedCommand(EditorCommandArgs args, Action nextCommandHandler)&#x000D;&#x000A;   at Microsoft.WebTools.Languages.Shared.Editor.Completion.TypingCommandHandler.ExecuteCommand(EscapeKeyCommandArgs args, Action nextCommandHandler, CommandExecutionContext executionContext)&#x000D;&#x000A;   at Microsoft.VisualStudio.UI.Text.Commanding.Implementation.EditorCommandHandlerService.&lt;&gt;c__DisplayClass14_1`1.&lt;ExecuteStartingAtIndex&gt;b__0()&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call, Predicate`1 exceptionFilter)&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)</description>
  </entry>

Last edited by jbirdman (2021-03-01 16:17:07)

2

Re: VS 2019 <Esc> does not exit insert mode in HTML files - causes error

Anyone else seeing this and maybe have a workaround?

I've tried to remove anything that might be affecting this, but you never know. Be helpful to know if others are seeing this as well.

Last edited by jbirdman (2021-04-19 20:07:11)

3

Re: VS 2019 <Esc> does not exit insert mode in HTML files - causes error

Hi jbirdman, sorry to not respond earlier. Esc handling in VS is quite messy, with the core text editor, language service, and all present 3rd party extensions intercepting it in awkward ways - plus of course Esc is not such an important functionality in any other area than vi emulation. It may very well be that the HTML language service is doing something quite weird that other language services don't. I plan to open source ViEmu in the near future, so hopefully that will help make it easier to debug this issue. Regards -- Jon