Code Monkey home page Code Monkey logo

collapsecomments's Introduction

Hi there ๐Ÿ‘‹

Recent blog posts


Anurag's github stats

collapsecomments's People

Contributors

mrlacey 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

Watchers

 avatar  avatar  avatar

collapsecomments's Issues

VS 17.4.5 Support

Nice work before all. I installed the extension in VS 17.4.5 and it's configurable from options panel, but it's invisible from contex menu, and the shortcut is assigned to schematization functions. Does the extension support recents VS releases?

Rather than collapse, could it not toggle back and forth?

First of all, thank you for developing this brilliant extension.

As the title says, could it not toggle rather than just collapse? That is, could it collapse and expand?

Also, and I figure it is a stretch, could it be made to work in "Preview" mode?

Much, much appreciated.

Automatically collapse on opening files

First, I love this extension. Thank you!

Installed product versions

  • Visual Studio: [2019 Professional]
  • This extension: [latest]

Description

I would like to option to automatically collapse all comments if I open a file.

Current behavior

On opening a file all comments are fully visible.

Expected behavior

On opening a file all comments should already be collapsed.

Enhancement: Collapsed comment should remove prefix /// <summary>

Installed product versions

  • Visual Studio: 2017 Enterprise
  • This extension: 1.0

Description

For better readability, collapsed comments should remove the prefix ///

This would make a collapsed comment consistent with the rendering of a collapsed #region section.

For example:

#region My Region
#endregion

collapses to

[My Region]

Therefore

/// <summary>
/// My summary
/// </summary>

should collapse to

[My summary]

Add outlining for multi-line C# comments

As can be seen from the below image, automatic outlining of multi-line comments isn't provided by default. This means that it's not possible to automatically collapse these comments.

image

Investigate adding additional outlining for such a comment, so that we can collapse (or expand) it.

X-Ref #11

console message driving me crazy

this message is making me crazy.. I cannot tell what extension it belongs to, the link shows many. But I can't find any of those when i sort my installed extensions in VS.

Please tell me what the name of it is so I can uninstall it, thanks!

Show your support by making a one-off or recurring donation at https://github.com/sponsors/mrlacey

If you become a sponsor, I'll tell you how to hide this message too. ;)

Compatibility issue with Tabs Studio

Visual Studio 17.6.5
While working on any file and randomly editing any line it causes the IDE to bug, breaking the { ... } collapsing of all blocks.
This issue start after installing the extension and I confirmed that I no longer get this issue after disabling it.

I have recorded a video, the issue start at 02:30 after clearing the */ you can see by the vertical dot lines, that everything got bugged now.

As I mentioned it happens randomly, I'm not sure if it could be a trigger but at 01:32 I called the shortcut to collapse everything.

The file I was working seen in the video:
gallery.zip

Things only back to normal after i clicking on a different file an returning back: video

Installation failure

Installed product versions

  • Visual Studio: Version: 1.63.2 (Universal)
  • This extension: Version | 2.0.1
  • OS: MacOS Monterey 12.1

Description

Using 'Install from VSIX' in VSCode yields "extension/package.json not found inside zip."

Any help would be much appreciated.

Steps to recreate

  1. Download the .vsix
  2. Under 'Extensions' click 'Install from VSIX...'

Current behavior

No installation

Expected behavior

Successful installation

"Expand only Comments" is confusing

Installed product versions

  • Visual Studio: Microsoft Visual Studio Community 2019 Version 16.5.4
  • This extension: 1.7

Description

Expand Only Comments collapses methods

Steps to recreate

  1. Right-Click text editor
  2. Select Expand Only Comments
  3. Collapses methods

Current behavior

Doesn't not collapse comments

Expected behavior

Supposed to expand comments and didn't touch anything else

text of the c# class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestSelectMasterSql
{
// class
// comment
class Class1
{
// method
// comment
void Method()
{
// first
// comment
var i = 1;
i = 2;
// second
// comment
i = 3;
i = 4;
i = 5;
}
}
}

image

Extension makes the Undo/Redo unusable [there's a fix]

Installed product versions

  • Visual Studio 2022 CE
  • CollapseComments v 2.5.1

Description

If I do:
Ctrl + M, Ctrl + M (collapsing everything)
I see only one entry in the Undo history

Ctrl + M, Ctrl + L (expanding everything)
this correctly adds only one entry in the Undo history

Ctrl + M, Ctrl + C (collapsing only the comments)
this correctly adds 100 entries in the Undo history if I have 100 functions in the code.

CollapseComments works very nicely, thanks a lot for that!,

but then every comments section that is collapsed adds one entry in the undo/redo history.

This not only is annoying and it makes the undo redo history useless, but also it makes VS unusable too, or very slow to say the least, if you try to undo like 20 of those undo entries.

There are two solutions for that.


### SOLUTION 1:
The simple workaround I used was to use this extension by Sergey Vlasov:
Disable Outlining Undo

reported in ide - Visual Studio _ exclude outlining from undo_redo stack - Stack Overflow

To have had the outlining actions go into the undo/redo history has always been a strong nuisance of Visual Studio for me (and clearly not only me).


In this extension the value of DefaultTextViewOptions.OutliningUndoOptionId is simply set to false.
Here is roughly a possible code equivalent to that of the 'Disable Outlining Undo' extension (using ChatGPT)

using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Formatting;

public class MyTextViewCreationListener : TextViewCreationListener
{
    public override void TextViewCreated(ITextView textView)
    {
        if (textView.Options is IEditorOptions editorOptions)
        {
            //getting the value
            object outliningUndoOptionId = textView.Options.GetOptionValue(DefaultTextViewOptions.OutliningUndoOptionId);
            int outliningUndoOptionIdValue = (int)outliningUndoOptionId;

            //setting the value to disable undo for outlines
            editorOptions.SetOptionValue(DefaultTextViewOptions.OutliningUndoOptionId, false);
        }
    }
}

Registering the TextViewCreationListener listener:

using Microsoft.VisualStudio.Shell;

protected override void Initialize()
{
    base.Initialize();

    var textViewCreationListener = new MyTextViewCreationListener();
    var textViewCreationService = GetService(typeof(ITextViewCreationListener)) as ITextViewCreationListener;

    if (textViewCreationService != null)
    {
        textViewCreationService.TextViewCreated += textViewCreationListener.TextViewCreated;
    }
}

A different implementation of this could be to simply to derive from
as explained in here and by MS here
Something on the line of (didn't test it):

using System;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;

[Export(typeof(IWpfTextViewCreationListener))]
[ContentType("text")]
[TextViewRole(PredefinedTextViewRoles.PrimaryDocument)]
internal sealed class MyWpfTextViewCreationListener : IWpfTextViewCreationListener
{
    public void TextViewCreated(IWpfTextView textView)
    {
        try
        {
            if (textView.Options.IsOptionDefined<bool>(DefaultTextViewOptions.OutliningUndoOptionId, false))
            {
                textView.Options.SetOptionValue<bool>(DefaultTextViewOptions.OutliningUndoOptionId, false);
            }
        }
        catch (Exception)
        {
        }
    }
}


If this idea would be integrated in the 'Collapse Comments' extension then it would be a good idea to re-enable the undo/redo stack after the outlining were concluded, or even better to restore the value of 'DefaultTextViewOptions.OutliningUndoOptionId' to the one it had before the collapsing operation was started.






### SOLUTION 2:
Even better would probably be to gather the entire action in a single undo/redo entry in the undo/redo history.

The raw code for this is (again using ChatGPT):

# References to add:
#   Microsoft.VisualStudio.Shell.17.0.dll
#   Microsoft.VisualStudio.Text.Data.17.0.dll
#   Microsoft.VisualStudio.Text.Logic.17.0.dll



using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Operations;
using Microsoft.VisualStudio.TextManager.Interop;

public class GroupUndoRedoExtension
{
    private IWpfTextView _textView;
    private IEditorOperations _editorOperations;

    public GroupUndoRedoExtension(IWpfTextView textView, IEditorOperationsFactoryService editorOperationsFactory)
    {
        _textView = textView;
        _editorOperations = editorOperationsFactory.GetEditorOperations(_textView);
    }

    public void GroupActions()
    {
        // Start a compound action to group multiple actions
        _editorOperations.BeginCompositeUndo();

        // Perform the individual actions
        // Example: Insert text at the current caret position
        _editorOperations.InsertText("Hello, World!");

        // End the compound action to group the actions
        _editorOperations.EndCompositeUndo();
    }
}



Sorry for using ChatGPT actually.


I hope this helps, and maybe it will be integrated one day in this extension.

Collapse to Comments (Ctrl+M, Ctrl+C) not working as expected when 'Collapse to definition' is used

Installed product versions

  • Visual Studio: 2019 Enterprise, 16.7.0
  • This extension: 1.9

Description

Collapse to Comments (Ctrl+M, Ctrl+C) not working as expected when 'Collapse to definition' is used

Steps to recreate

  1. Outlining -> Collapse to definition (Ctrl+M,O)
  2. Outlining -> Collapse to Comments (Ctrl+M, Ctrl+C)

Current behavior

Nothing happens

Expected behavior

Collapse to Comments (Ctrl+M, Ctrl+C) should collapse comments and expand method definitions.

Improve javascript support

According to a recent review

Do note (at least in JavaScript) that your comment needs to be a block (> 1 line) to be collapsible.

I assume this means that comments

/**
 * like this
 */

aren't supported.

Add the ability to collapse Attributes spread over multiple lines

As per the example below, the arguments for an attribute are spread over multiple lines and so take up lots of vertical space in the editor.

As the attribute (& arguments) aren't always important I'd like to be able to collapse them away.

image

This should collapse to something like the following so it's still possible to see what the attribute is.

[SuppressMessage(...)]

Custom collapse?

Hello, is it possible to shortcut a command to collapse only specific lines?

Example:

// aaa
// bbb
// ccc

With a hotkey collapse all lines that start or which contain // aaa. Environment c++

Feature request: More collapse options

  • Visual studio 2019.

Hello, mrlacey!

Would like to request two features, if possible.

  1. A shortcut in which collapse everything less comments?
    I know is possible to achieve it with CTRL+M, CTRL+O (collapse everything) then CTRL+M, CTRL+D (unfold comments), but would be better with just one shortcut.

  2. Possibility to choose which comments will be folded, for example: // or /* */, or both.

I'm currently using the extension with c++.
Thank you for such useful extensions.

Is this extension currently functioning?

Installed product versions

  • Visual Studio: 2019
  • This extension: 1.1

Description

Does the latest version of this extension work with the latest version of Visual Studio?

I haven't used the extension before, and after installing it the hotkey command does not appear to do anything. Just wanted to do a sanity check.

Unexpected behavior of "Include using directive"

Installed product versions

  • Visual Studio: Community 2022 (64-bit) - Version 17.7.6
  • This extension: v2.5

Description

Unchecking "Include using directives" works with Ctrl-M, Ctrl-C, but not with "Run when document opened"

Steps to recreate

  1. Close all files
  2. Open Options, navigate to Collapse Comments
  3. Set "Include using directives" to false
  4. Set "Run when document opened" to true
  5. Apply and close options
  6. Open a C# file

Current behavior

All comment blocks and using blocks will be collapsed
Further, expanding with Ctrl-M,Ctrl-D does not expand the using blocks

Expected behavior

All comment blocks will be collapsed, but using blocks stay expanded

Not collapsing on VS22 17.5.3

In the doc it says:

Ctrl+M, Ctrl+D expands all comments (and collapses everything else.)

When i press the shortcut its not collapsing anything, just expanding the comments.

Also, looks like after I installed the extension its causing any kind of conflict on the IDE, it now randomly starts unfolding collapsed blocks, have you experience this issue before?

I'm testing on Windows 10, and working on a c++ project.

Using directives are not collapsed automatically

Installed product versions

  • Visual Studio: Visual Studio Enterprise 2022 (64-bit) - Version 17.1.0 Preview 3.0
  • This extension: 2.0.1

Description

This extension works on a new console application (.NET 6) and the Roslyn repository. But i cannot get it to work on another solution

Steps to recreate

  1. Change the extension configuration from the VS options
    • Include using directives: true
    • Run when document opened: true
  2. Clone https://github.com/meziantou/Meziantou.Framework.git
  3. Open Meziantou.Framework.sln
  4. Open a c# file

Current behavior

The using directives are not collapsed automatically

image

Expected behavior

Using directives are collapsed

By curiosity, why does it take a few seconds to collapse the section? Is it a limitation of VS?

Feature: Include whitespace

Would it be possible to include whitespace when collapsing comments?

So that

// Comment

// More comments
// Still more comments

would be able to collapse as one block? Maybe it would be worthwhile to retain sub-blocks for each section if desired, but it would be nice if comments separated only by whitespace would be able to combine at the very least.

[Feature Request] Fold active block

  • Visual Studio: 2022

Would like to request a hotkey to fold the currently active block, for example:

image

When I have the caret in line 42 and press the hotkey it would fold only the content of

        for (int i = 0; i < sv.size(); i++)
        {
            eff = new GraphicsEffect(sv[i].blurRadius, sv[i].distance,
                sv[i].angle, sv[i].shadow_color);
            sv[i].widget->setGraphicsEffect(eff);
        }

When I have the caret in line 39 it would fold everything from line 38 to 46

How to change configuration options?

Could you please tell where can I change these options?

  • collapse (or expand) using/import directives
  • auto-collapse when opening a file

I can't find any documentation about this.

Visual Studio crashes when opening files

Installed product versions

  • Visual Studio:
    Microsoft Visual Studio Community 2022 (64-bit) - Current
    Version 17.8.7
  • This extension: 2.6

Description

Visual Studio crashes when opening files in project. This happens 100% for me in the below project.

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
at CollapseComments.CollapseCommand+d__6.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.VisualStudio.Threading.JoinableTaskFactory+SingleExecuteProtector.TryExecute()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)

Steps to recreate

  1. Clone https://github.com/tryAGI/LangChain
  2. Open the sln
  3. Open a couple of files, maybe navigate to definition (F12)

Current behavior

Visual Studio freezes and then crashes

Expected behavior

Not crashing

Toggling Does Not Work in 2022 17.8.1

Installed product versions

  • Visual Studio: Community 2022 (64-bit) 17.8.1
  • This extension: 2.5

Description

Toggling comments does not work.

Steps to recreate

  1. Install extension.
  2. Select all.
  3. Press CTRL-M, CTRL-F

This issue persists when:

  • All other extensions are disabled,
  • Visual Studio is reinstalled.
  • All other keyboard commands for this extension have been removed,
  • The toggle keyboard command is remapped (for example, CTRL-M, CTRL-C),
  • Toggling is selected from the context menu.

Current behavior

Toggling comment expansion does not work.

Expected behavior

Toggling comment expansion should work.

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.