Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VsVim for Mac: Rename refactoring does not work #2763

Closed
coolbluewater opened this issue Jan 7, 2020 · 17 comments · Fixed by #2778
Closed

VsVim for Mac: Rename refactoring does not work #2763

coolbluewater opened this issue Jan 7, 2020 · 17 comments · Fixed by #2778
Assignees

Comments

@coolbluewater
Copy link

coolbluewater commented Jan 7, 2020

Migrated from #2733

Thanks for the plugin! I've run into the refactoring/renaming issue discussed above. On my mac, with VsVim enabled, doing a rename refactoring does not work. The text is highlighted, and I can enter the new name, but when I press enter, the highlight disappears and the old name returns. No changes occur.

I have to disable the VsVim plugin and restart VSMac for renaming to start working again. (The rename itself is sometimes buggy and garbles text, but that I assume is a separate VSMac bug.)

I am using the latest Preview build of VSMac 8.4 (build 2653) and a build from the current sources of VsVim following the instructions list in the above mentioned thread.

@nosami

@nosami nosami self-assigned this Jan 7, 2020
@nosami
Copy link
Collaborator

nosami commented Jan 7, 2020

I tried to reproduce this tons of times before and couldn't but I just tried and it reproduced the first time. I'll take a look at it as soon as I can.

@coolbluewater
Copy link
Author

Were you able to figure this out? Enjoying the plugin but this one nit has me shifting between VsMac and vscode a lot. Can't wait to ditch electron! :)

@kendallroth
Copy link

I've tried a bunch of different things to make it work, but have been unsuccessful so far as well. Definitely a large downside to what is an excellent plugin otherwise!

@nosami
Copy link
Collaborator

nosami commented Feb 8, 2020

Sorry about this. Haven't had time to look into it yet.

@nosami
Copy link
Collaborator

nosami commented Feb 8, 2020

For me it works every time until I see "External edit detected" in the status bar. After that, it never works. I will do some digging.

@nosami
Copy link
Collaborator

nosami commented Feb 8, 2020

Are any of you able to build the plugin from source code?

I don't really understand how most of this code is intended to work yet... but it seems like switching the EnableExternalEditMonitoring setting fixes things for me; looks like this setting is intended for other 3rd party tools that can modify source code, e.g. Resharper which we don't have to worry about right now on Mac.

Switching the default setting from true to false seems to work. Not sure if there are any downsides.

index ef236156..b96fb42d 100644
--- a/Src/VimMac/VimApplicationSettings.cs
+++ b/Src/VimMac/VimApplicationSettings.cs
@@ -124,7 +124,7 @@ namespace Vim.VisualStudio.Implementation.Settings

         bool IVimApplicationSettings.EnableExternalEditMonitoring
         {
-            get { return GetBoolean(EnableExternalEditMonitoringName, defaultValue: true); }
+            get { return GetBoolean(EnableExternalEditMonitoringName, defaultValue: false); }
             set { SetBoolean(EnableExternalEditMonitoringName, value); }
         }

nosami added a commit to nosami/VsVim that referenced this issue Feb 8, 2020
I don't fully understand why this works and didn't try to understand
either. It seems like we should just not use this setting on MacOS
(we don't have any 3rd party addins that can modify source code on Mac)

Fixes VsVim#2763
@coolbluewater
Copy link
Author

I just built from source, happy to report that renaming succeeds. Just starting a coding session, will update if anything else breaks.

@kendallroth
Copy link

I can also confirm that a build from source (master branch) appears to have resolved the issue for the moment, will continue to monitor.

nosami added a commit to nosami/VsVim that referenced this issue Feb 8, 2020
I don't fully understand why this works and didn't try to understand
either. It seems like we should just not use this setting on MacOS
(we don't have any 3rd party addins that can modify source code on Mac)

Fixes VsVim#2763
nosami added a commit to nosami/VsVim that referenced this issue Feb 8, 2020
I don't fully understand why this works and didn't try to understand
either. It seems like we should just not use this setting on MacOS
(we don't have any 3rd party addins that can modify source code on Mac)

Fixes VsVim#2763
@nosami
Copy link
Collaborator

nosami commented Feb 8, 2020

@kendallroth did you apply the diff above to master? Because master by itself doesn't contain the fix.

Try and build from this PR if you can.

Cheers.

@kendallroth
Copy link

Ah, I did not. It works for a bit but eventually I am forced to close VS entirely and restart if I want to get it working. I've pulled from your repo now and will be checking again.

@kendallroth
Copy link

Unfortunately I'm running into the same issue, where every now and again it "borks" itself and starts changing the variable name back when hitting <enter>.

@coolbluewater
Copy link
Author

Sadly, the fix doesn't work for me anymore either. After the first couple of successes reported above, the old behavior returned.

@costoda-ey
Copy link

I am too seeing this issue on my Mac that I'm not building from Source.

@nosami
Copy link
Collaborator

nosami commented Feb 17, 2020

I just happened to be debugging VSMac when I hit this error again. Making a note here for when I come to take another look

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: GetTextViewLineContainingBufferPosition called after the view is closed
  at Microsoft.VisualStudio.Text.Editor.Implementation.BaseTextView.GetTextViewLineContainingBufferPosition (Microsoft.VisualStudio.Text.SnapshotPoint bufferPosition) [0x00023] in /Users/jasonimison/src/vsmac/main/external/vs-editor-core/src/Editor/Text/Impl/BaseViewImpl/BaseTextView.cs:696 
  at Vim.Mac.CaretUtil.SetCaret (Vim.IVimBuffer vimBuffer) [0x00069] in <1086c9d84f354bf38ca7ab1839e79cb2>:0 
  at Vim.Mac.CaretUtil+<>c__DisplayClass1_0.<Vim.IVimBufferCreationListener.VimBufferCreated>b__0 (System.Object _, Vim.SwitchModeEventArgs __) [0x00000] in <1086c9d84f354bf38ca7ab1839e79cb2>:0 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 
   --- End of inner exception stack trace ---
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007e] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:409 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-12/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/Reflection/MethodBase.cs:53 
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000e1] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System/Delegate.cs:465 
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00008] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System/MulticastDelegate.cs:67 
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System/Delegate.cs:410 
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x0001b] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System/MulticastDelegate.cs:72 
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System/Delegate.cs:410 
  at Microsoft.FSharp.Control.FSharpDelegateEvent`1[TDelegate].Trigger (System.Object[] args) [0x0000a] in <5e0fe3d9b6bc8869a7450383d9e30f5e>:0 
  at Vim.ModeMap.SwitchMode (Vim.ModeKind kind, Vim.ModeArgument arg) [0x00058] in <5e0fe3d9b6bc8869a7450383d9e30f5e>:0 
  at Vim.VimBuffer.SwitchMode (Vim.ModeKind modeKind, Vim.ModeArgument modeArgument) [0x00015] in <5e0fe3d9b6bc8869a7450383d9e30f5e>:0 
  at Vim.VimBuffer.SwitchPreviousMode () [0x00048] in <5e0fe3d9b6bc8869a7450383d9e30f5e>:0 
  at Vim.VimBuffer.Vim-IVimBuffer-SwitchPreviousMode () [0x00015] in <5e0fe3d9b6bc8869a7450383d9e30f5e>:0 
  at Vim.UI.Cocoa.Implementation.InlineRename.InlineRenameListenerFactory.OnIsRenameActiveChanged (System.Object sender, System.EventArgs e) [0x0004e] in <1086c9d84f354bf38ca7ab1839e79cb2>:0 
  at Vim.UI.Cocoa.Implementation.InlineRename.InlineRenameUtil.OnActiveSessionChanged (System.Object sender, System.EventArgs e) [0x0000a] in <1086c9d84f354bf38ca7ab1839e79cb2>:0 
  at (wrapper delegate-invoke) System.EventHandler`1[Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameService+ActiveSessionChangedEventArgs].invoke_void_object_TEventArgs(object,Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameService/ActiveSessionChangedEventArgs)
  at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameService.set_ActiveSession (Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession value) [0x0000f] in /Users/jasonimison/src/vsmac/main/external/vs-editor-core/src/Editor/Roslyn/EditorFeatures/Cocoa/InlineRename/InlineRenameService.cs:100 
  at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.Dismiss (System.Boolean rollbackTemporaryEdits) [0x000e3] in /Users/jasonimison/src/vsmac/main/external/vs-editor-core/src/Editor/Roslyn/EditorFeatures/Cocoa/InlineRename/InlineRenameSession.cs:358 
  at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.CommitCore (Microsoft.CodeAnalysis.Editor.Host.IWaitContext waitContext, System.Boolean previewChanges) [0x000e8] in /Users/jasonimison/src/vsmac/main/external/vs-editor-core/src/Editor/Roslyn/EditorFeatures/Cocoa/InlineRename/InlineRenameSession.cs:697 
  at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession+<>c__DisplayClass73_0.<Commit>b__0 (Microsoft.CodeAnalysis.Editor.Host.IWaitContext waitContext) [0x00000] in /Users/jasonimison/src/vsmac/main/external/vs-editor-core/src/Editor/Roslyn/EditorFeatures/Cocoa/InlineRename/InlineRenameSession.cs:640 
  at MonoDevelop.Ide.Composition.RoslynWaitIndicator.Wait (System.String title, System.String message, System.Boolean allowCancel, System.Boolean showProgress, System.Action`1[T] action) [0x0000e] in /Users/jasonimison/src/vsmac/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Composition/RoslynWaitIndicator.cs:29 
  at Microsoft.CodeAnalysis.Editor.Host.IWaitIndicatorExtensions.Wait (Microsoft.CodeAnalysis.Editor.Host.IWaitIndicator waitIndicator, System.String title, System.String message, System.Boolean allowCancel, System.Action`1[T] action) [0x00000] in /_/src/EditorFeatures/Core/Host/IWaitIndicator.cs:21 
  at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.Commit (System.Boolean previewChanges) [0x00062] in /Users/jasonimison/src/vsmac/main/external/vs-editor-core/src/Editor/Roslyn/EditorFeatures/Cocoa/InlineRename/InlineRenameSession.cs:636 
  at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.RenameCommandHandler.ExecuteCommand (Microsoft.VisualStudio.Text.Editor.Commanding.Commands.ReturnKeyCommandArgs args, Microsoft.VisualStudio.Commanding.CommandExecutionContext context) [0x00014] in /Users/jasonimison/src/vsmac/main/external/vs-editor-core/src/Editor/Roslyn/EditorFeatures/Cocoa/InlineRename/CommandHandlers/RenameCommandHandler_ReturnHandler.cs:22 
  at Microsoft.VisualStudio.Commanding.CommandHandlerExtensions.ExecuteCommand[T] (Microsoft.VisualStudio.Commanding.ICommandHandler commandHandler, T args, System.Action nextCommandHandler, Microsoft.VisualStudio.Commanding.CommandExecutionContext executionContext) [0x0003b] in /Users/jasonimison/src/vsmac/main/external/vs-editor-core/src/Editor/Text/Def/TextUI/Commanding/CommandHandlerExtensions.cs:102 
  at Microsoft.VisualStudio.UI.Text.Commanding.Implementation.EditorCommandHandlerService+<>c__DisplayClass15_1`1[T].<Execute>b__1 () [0x00018] in /Users/jasonimison/src/vsmac/main/external/vs-editor-core/src/Editor/Text/Impl/Commanding/EditorCommandHandlerService.cs:137 
  at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint (System.Object errorSource, System.Action call, System.Predicate`1[T] exceptionFilter) [0x0000f] in /Users/jasonimison/src/vsmac/main/external/vs-editor-core/src/Editor/Text/Util/TextDataUtil/GuardedOperations.cs:405 

@nosami
Copy link
Collaborator

nosami commented Feb 17, 2020

I think this PR is working now. Looks like I introduced an error in the last commit.

@coolbluewater
Copy link
Author

Thanks! After encountering #2783 I built and installed from source, and a couple of test renames succeeded.

@funseiki
Copy link

Works for me as well. Got the latest via the update. Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants