Giter VIP home page Giter VIP logo

hotcommands's Introduction

Welcome to the Justcla repos!

Justin is a Product Manager and Software Engineer with over twenty years' experience in software development and has worked for several large organisations including Google, Microsoft, Amazon, NewsCorp, Symantec, Booking.com, and more!

  • Senior Technology Product Manager @Booking.com.
  • Formerly Product Manager for Android Studio @Google.
  • Formerly Program Manager on the Visual Studio IDE team at @Microsoft
  • Formerly Senior Software Engineer for AzureDevOps @Microsoft

hotcommands's People

Contributors

aakash-1906 avatar amadeusw avatar carsonal avatar cfognom avatar justcla avatar lordofstuff avatar lorenpaulsen avatar pramod-hegde avatar tiesmaster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hotcommands's Issues

Increase Selectionw works only in C# files

Hi,

Fantastic extensions with one small problem. Ctrl+w works only in C# files.

Is here any workaround how to use ctrl+w for C# class and classic ctrl+w in other files(html,css)

Thanks

Re-write DuplicateSelection

The code for DuplicateSelection uses EditorOperations and doesn't work well with multiple cursors.
It's also not really clean and has much duplication.
This code should be written much more like DuplicateLines, carefully avoiding moving the caret unless necessary.

Hey Carl, @cfognom , Can you please take a look while your knowledge is fresh?

Fix Warning that appears at VS launch after installing HotCommands

Error occurs when VS opens.

image

'
Could not load file or assembly 'Microsoft.VisualStudio.Threading, Version=17.5.0.0
'

Still unable to load MEF component DLL: Could not load file or assembly 'Microsoft.VisualStudio.Threading, Version=17.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)          C:\Users\Justin\AppData\Local\Microsoft\VisualStudio\17.0_6b28b076\Extensions\pq0u3rou.bbr\HotCommands.dll


SetSite failed for package [VSShortcutsManagerPackage]Source: 'KeyboardShortcutsManager' Description: Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object. at VSShortcutsManager.ShortcutsScanner.ScanForNewShortcutsDefs() in C:\Projects\VSShortcutsManager\VSShortcutsManager\ExtensionScanner\ShortcutsScanner.cs:line 250 at VSShortcutsManager.ShortcutsScanner.ScanForAllExtensionShortcuts() in C:\Projects\VSShortcutsManager\VSShortcutsManager\ExtensionScanner\ShortcutsScanner.cs:line 193 at VSShortcutsManager.VSShortcutsManager..ctor(Package package) in C:\Projects\VSShortcutsManager\VSShortcutsManager\VSShortcutsManager.cs:line 137 at VSShortcutsManager.VSShortcutsManagerPackage.<InitializeAsync>d__7.MoveNext() in C:\Projects\VSShortcutsManager\VSShortcutsManager\VSShortcutsManagerPackage.cs:line 51 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass21_0.<<Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize>b__1>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e) at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)

Edit.ToggleComment Bug ?

Edit.ToggleComment is not working in ascx/aspx editor in vs2017
Edit.DuplicateSelection also is not working.

Is there some setting to be enabled/disabled to enable shortcuts in ascx/aspx editor?

Duplicate selection needs this!

Hi, I detected a "problem" in the 2022 version of this plugin, example:

I select for example 3 lines, and select it in the middle like in the image attached.
When I use the command to duplicate it needs to duplicate the entire 3 lines, no only the selection.

Capturar

The builtin command in VS duplicates the selection only, I think in the 2017 your extension duplicates the entire lines if they are partially selected.
This is the behavior of all editors that I can remember, and I think is a good thing to differentiate you plugin from the builtin from VS2022.

Can't build project

I just forked the repo and opened it in Visual Studio 2017 and all the package references in the .csproj file points to ..\Packages\* instead of ..\..\Packages\* so I can't build the project

InvalidOperationException on InitializeFieldFromConstructor

Hi. In VS 2017.2 often see exception in InitializeFieldFromConstructor while edit code in .net core projects (1.1).

System.InvalidOperationException : Sequence contains more than one element
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
   at HotCommands.InitializeFieldFromConstructor.GetConstructors(VariableDeclaratorSyntax fieldVariable)
   at async HotCommands.InitializeFieldFromConstructor.ComputeRefactoringsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.GetRefactoringFromProviderAsync(<Unknown Parameters>)

Exceptions thrown at VS statup

I can reliably reproduce this issue now and finally managed to capture the extension log as well. Somehow starting VS with the /log switch wouldn't create the log file at the default (AppData/Roaming/...) location even though the error dialog that popped up indicated exactly that. I had to specify the log file path explicitly for the logging to kick in. Anyhow, please find ActivityLog.xml attached. To reproduce the issue I have to start two VS instances. The second instance triggers a "Loading user settings (...)" dialog while starting up (and this is the root cause of the issue, I think), then the usual error dialog pops up saying that there may be problems with some extensions. Records 690, 691, and 693 contain the pertaining exceptions.

ActivityLog.zip

Add command: Format code

Shortcut Key: Ctrl-Alt-L

If no selection, will apply Edit.FormatDocument
else will apply Edit.FormatSelection

Solution doesn't build in VS 2019

As discussed in #81, and #82, the build is failing, and needs to be fixed before #82 can be merged.

When opening up HotCommands.sln in VS 2019, I now get

Commands\ToggleComment.cs(13,30): error CS0234: The type or namespace name 'Language' does not exist in the namespace 'Microsoft.VisualStudio' (are you missing an assembly reference?) [C:\src\oss\HotCommands\HotCommands\HotCommands.csproj]

I've tracked that down to missing nuget reference in packages.config, commit 34cf0de fixes that, but results in another build error:

The "ValidateVsixManifest" task failed unexpectedly.
System.ArgumentNullException: Value cannot be null.
Parameter name: path1
   at System.IO.Path.Combine(String path1, String path2, String path3)
   at Microsoft.VisualStudio.Sdk.BuildTasks.ValidateVsixManifestUtilitiesLegacy.ValidateVsix(TaskLoggingHelper log, String manifestToValidate, String vsixSchemaPath, Boolean validateEverything, String& name, String& id)
   at Microsoft.VisualStudio.Sdk.BuildTasks.ValidateVsixManifest.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Don't really understand what's going on there, so I need to dig into that.

Shortcuts are always rebound on VS startup Without Fail

Hi, thanks for writing this extension, I would like to continue to use it but unfortunately, there is an issue which makes it absolutely, maddeningly unusable for me.

Whenever I start Visual Studio, HotCommands rebinds all of its keybindings, recreating them even if they have been overwritten, changed, or removed.

I use a keyboard profile which is a derivative of the "Visual C# 2005" preset in Visual Studio and thus uses
Ctrl+W as the first combination for chord based commands such as View.Solution Explorer, View.TeamExplorer, View.Errors, and so on. I defined Ctrl+W, Ctrl + W / Ctrl+W, W, as a shortcut for Window.CloseDocumentWindow. I mention this last one because HotCommands causes VS to throw a modal Error whenever I hit Ctrl+W, Ctrl+W.

Naturally, I have tried binding Edit.IncreaseSelection to a different hotkey and removing the assignment created by this extension. This has no lasting effect as it is recreated, without fail, each and every time I start VS as soon as I load any file. I have to remove the binding for Ctrl+W every time a start VS.

This took me a while to track down because I have a fair number of extensions installed and because I frankly forgot that Edit.IncreaseSelection is a command created by this extension.

I am using Visual Studio 2017 RC, and am running Windows 10 Pro.

ToggleComment Issues

Just ran into 2 issues with the ToggleComment command.

The first one is more of an unexpected difference in implementation.  Having worked with various editors (Sublime Text, Atom, Light Table, misc JetBrains IDEs, etc.), the 'move down a line after commenting' action is something I've never come across until now.  Any way this could be implemented as an option? 

The second one pertains to text in the surrounding regions of the selection.  For some reason, it becomes indented after the selected region is uncommented:

hotcommands_comment

Add refactoring: Change signature (append parameter)

Example:

Method already exists: Foo(Bar bar1);

While calling it we decide to add another parameter:
Foo(myBar1, myBar2);

Lightbuld should suggest "Change signature of Foo to add Bar as 2nd parameter"
and result in a new parameter added to the Foo method:
eg. Foo(Bar bar1, Bar bar2);
and updates all other calls to include some default value for the second parameter (or provide a change signature dialog that allows you to specify what the new default value might be).

Move Member Up/Down commands do not work in VB.NET

For me the command "Move Member Up/Down" does not work at all. I did not manage to make it work at all. I'm getting the "Nullable object must have value" error message.

2017-09-15_1119

I'm using Visual Studio 2017 for VB.NET development.

By the way the "Go To Previous/Next Member" does not work either. It does nothing. No error message, no beep sound. I'm mentioning it as it might be related. Fortunately this command is replacable with VS's native "Next/Previous Method". It cycles not only methods, but also properties and fields. It skips delegates and events though (so that is why Go To Previous/Next Member" still has sense).

This is the sample class to test with:

Public Class SampleClass

    Public Property First As Boolean

    Public Property Second As String
        Get
            Return Nothing
        End Get
        Set(value As String)
            ' noop
        End Set
    End Property

    Private ReadOnly Property Third As Integer
        Get
            Return 0
        End Get
    End Property

    Public Event OnFooBar()

    Public Delegate Sub DoSomething()

    Public Delegate Function DoSomethingElse() As Boolean

    Private ReadOnly _x As Boolean
    Private ReadOnly _y As Integer
    Private ReadOnly _z As String

    Public Sub New()

    End Sub

    Public Sub Foo()

    End Sub

    Public Function Bar() As Integer
        Return Third
    End Function

End Class

InitializeFieldFromConstructor causes exception

User Maarten Boelens reported error on Developer Community.

I keep getting a InitializeFieldFromConstructor exception (yellow bar on top of the editor) just by clicking on a private field. Here's the stack trace:
System.NullReferenceException : Object reference not set to an instance of an object. at HotCommands.InitializeFieldFromConstructor.<>c_DisplayClass1_0.b_0(ConstructorDeclarationSyntax x) at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Linq.Enumerable.Count[TSource](IEnumerable1 source) at async HotCommands.InitializeFieldFromConstructor.ComputeRefactoringsAsync() at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.GetRefactoringFromProviderAsync()

Add command: DuplicateLinesUp (a.k.a. CopyLinesUp)

Question asked on Visual Studio Marketplace: By Carl Foghammar Nömtak 9/02/2023

It would be nice with an Edit.DuplicateLines that copies upward, in addition to the current one. So we can replicate functionality of vs code shift + alt + up/down.

Attempting to Install to VS 2017 Results in NullReferenceException

Here's the log entry that was generated:

19/12/2016 7:04:29 PM - Microsoft VSIX Installer
19/12/2016 7:04:29 PM - -------------------------------------------
19/12/2016 7:04:29 PM - vsixinstaller.exe version:
19/12/2016 7:04:29 PM - 15.0.26014.0 built by: D15REL
19/12/2016 7:04:29 PM - -------------------------------------------
19/12/2016 7:04:29 PM - Command line parameters:
19/12/2016 7:04:29 PM - C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\vsixinstaller.exe,/appidinstallpath:C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe,/skuName:Enterprise,/skuVersion:15.0.26014.0,/appidname:Microsoft Visual Studio Enterprise 2017 RC,C:\Users\Yann\AppData\Local\Temp\VSIXvrc0roc3.vsix
19/12/2016 7:04:29 PM - -------------------------------------------
19/12/2016 7:04:29 PM - Microsoft VSIX Installer
19/12/2016 7:04:29 PM - -------------------------------------------
19/12/2016 7:04:29 PM - Initializing Install...
19/12/2016 7:04:29 PM - Extension Details...
19/12/2016 7:04:29 PM - Identifier : e8175b11-0e09-42b5-9c3c-ba7bfb53a311
19/12/2016 7:04:29 PM - Name : Hot Commands for Visual Studio
19/12/2016 7:04:29 PM - Author : Justin Clareburt
19/12/2016 7:04:29 PM - Version : 1.1.3
19/12/2016 7:04:29 PM - Description : A collection of commands, analyzers, and refactorings for enhanced productivity in Visual Studio IDE
19/12/2016 7:04:29 PM - Locale : en-US
19/12/2016 7:04:29 PM - MoreInfoURL : https://marketplace.visualstudio.com/items?itemName=JustinClareburtMSFT.HotCommandsforVisualStudio
19/12/2016 7:04:29 PM - InstalledByMSI : False
19/12/2016 7:04:29 PM - SupportedFrameworkVersionRange : [4.5,)
19/12/2016 7:04:29 PM -
19/12/2016 7:04:29 PM - SignatureState : Unsigned
19/12/2016 7:04:29 PM - Supported Products :
19/12/2016 7:04:29 PM - Microsoft.VisualStudio.Community
19/12/2016 7:04:29 PM - Version : [14.0,16.0)
19/12/2016 7:04:29 PM -
19/12/2016 7:04:29 PM - References :
19/12/2016 7:04:29 PM - Prerequisites :
19/12/2016 7:04:29 PM - -------------------------------------------------------
19/12/2016 7:04:29 PM - Identifier : Microsoft.VisualStudio.Component.CoreEditor
19/12/2016 7:04:29 PM - Name : Visual Studio core editor
19/12/2016 7:04:29 PM - Version : [15.0.25826.2,16.0)
19/12/2016 7:04:29 PM -
19/12/2016 7:04:29 PM - Signature Details...
19/12/2016 7:04:29 PM - Extension is not signed.
19/12/2016 7:04:29 PM -
19/12/2016 7:04:31 PM - The extension with ID 'e8175b11-0e09-42b5-9c3c-ba7bfb53a311' is not installed to Microsoft Visual Studio Enterprise 2017 RC.
19/12/2016 7:04:31 PM - System.NullReferenceException: Object reference not set to an instance of an object.
at VSIXInstaller.LocationBasedSKU.IntializePackages()
at VSIXInstaller.LocationBasedSKU.GetSetupDependencies(IInstallableExtension extension, ICollection1 installedPackages, ICollection1 installablePackages, ICollection1 unresolvedReferences) at VSIXInstaller.LocationBasedSKU.GetSetupDependencies(IInstallableExtension extension, IEnumerable1& installedPackages, IEnumerable1& installablePackages, IEnumerable1& unresolvedReferences)
at VSIXInstaller.App.GetInstallableData(String vsixPath, Boolean isRepairSupported, IEnumerable1& skuData) at VSIXInstaller.App.Initialize(Boolean isRepairSupported) at VSIXInstaller.App.Initialize() at System.Threading.Tasks.Task1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()

Support for C/C++

This is not really an issue, just a question. The extension is great by the way and it's an awesome addition to C# editing experience but I was wondering how difficult would it be to make it compatible with C/C++ or what the challenges are to make that happen.

Thanks!

Add command: Join Lines

IntelliJ command: Smart Line Join
Suggested shortcut: Ctrl+Shift+J

Brings previous line up to current line.
Removes redundant whitespace.

Clever trick: If joining a variable assignment onto code that has just declared the variable, will merge the variable declaration and assignment together (includes removing any redundant variable declaration and removing semi-colon).
This should effectively reverse a "Split variable declaration and assignment" code refactoring.

Add command: Overwrite/Replace with IntelliSense

Suggested key binding: Tab

Enter key should simply insert IntelliSense.
Tab key should insert the IntelliSense and replace everything to the right of the cursor - until the next space or bracket appears.

HotCommand uses legacy API in VS 2019

First, HotCommands is awesome ❤️

I don't know if you noticed (see screenshot below), but VS 2019 now marks any extensions still using the "sync" Package base class get marked as using a deprecated API, and are advised to upgrade to the new-ish AsyncPackage API. The "Learn More" points to this page.

image

Exception when opening C# Interactive

It tells me an exception happened and that I should see the log to know what happened:
<entry> <record>1135</record> <time>2018/09/13 13:36:18.108</time> <type>Error</type> <source>Editor or Editor Extension</source> <description>System.NullReferenceException: Object reference not set to an instance of an object.&#x000D;&#x000A; at HotCommands.LastEditHandler.GetCurrentFilePath() in C:\Projects\HotCommands\HotCommands\Listeners\LastEditTextViewCreationListener.cs:line 54&#x000D;&#x000A; at HotCommands.LastEditHandler.RecordLastEdit(Object sender, EventArgs e) in C:\Projects\HotCommands\HotCommands\Listeners\LastEditTextViewCreationListener.cs:line 45&#x000D;&#x000A; at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.RaiseEvent(Object sender, EventHandler eventHandlers)&#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>

Hilarious build warning

While not an ERROR, I found this build warning too hilarious to not share. I just love the Zen-like tension in it, and the GNU-inspired recursion (VS2017 26228.9):

1>CSC : warning AD0001: Analyzer 'Microsoft.CodeAnalysis.CSharp.Analyzers.FixAnalyzers.CSharpFixerWithFixAllAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'Microsoft.CodeAnalysis.Analyzers.FixAnalyzers.FixerWithFixAllAnalyzer`1' threw an exception.'.

Change Modifiers refactoring throws on non-classes

Change Modifiers was crashes for me repeatedly the other day, with the following stacktrace:

System.InvalidOperationException : Sequence contains no elements
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at async HotCommands.ChangeModifierAction.GetChangedDocumentAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputePreviewOperationsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewResultAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.<>c__DisplayClass11_0.<GetPreviewAsync>b__0(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)

Looking at the code, I see it's because it assumes it's always on a class, but in my case, I'm on an interface.

Maybe a bit redundant, but Steps to reproduce:

  1. Put the cursor on an interface, and
  2. Preview one of the change modifier refactorings

BOEM

The Single() on ChangeModifierAction.cs:L38 is obviously the cause of the bug, and since the result of that LINQ query is checked for null, it looks like SingleOrDefault() makes more sense here. For me that fixes the problem. Do want a PR for that?


On a side note, it's unfortunately that this refactoring doesn't work on interfaces, and when I change the OfType<ClassDeclarationSyntax> to BaseTypeDeclarationSyntax, then it works me on interfaces, as well. Any idea why you made this specifically only work on classes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.