Code Monkey home page Code Monkey logo

Comments (6)

snoopy avatar snoopy commented on June 16, 2024 2

There's probably an elegant way to solve it, but I haven't found it yet.

The elegant way is to correctly guess the users intent which is not really feasible. That's why I am using two different hotkeys for commenting. One for the default toggle and one to comment everything that is selected. Considering how rarely I use the latter this is acceptable to me.
Just for comparison, vscode doesn't seem very smart about commenting either. It will often double comment lines which is even more annoying than having two different hotkeys.

from textadept.

snoopy avatar snoopy commented on June 16, 2024 1

I'm also using a customized comment function that allows for this. At the time I was the only one who expressed interest in this, which is why I didn't really push for upstream integration.
It's implemented as an argument so both versions are possible. Additionally, my function inserts a space between the comment token and the text for added clarity.

The changes are minor but I'm still not sure it's worth to integrate into upstream since it is easily implemented in the local init.lua.

from textadept.

orbitalquark avatar orbitalquark commented on June 16, 2024 1

I can't reproduce the problem where toggling again doesn't restore the original.

When you "toggle comment" on a line that starts with a comment, I would expect that line to be uncommented, hence my comment. I'm not belittling your solution though. I was just hoping to try and come up with something more elegant that makes a bit more intuitive sense.

from textadept.

orbitalquark avatar orbitalquark commented on June 16, 2024

The one issue is if you start with a commented line and extend the selection to the line below, for example:

#foo
bar

When you toggle comment, you'll get this:

foo
ar

Toggling again gives you:

#foo
#ar

The idea of "toggle comment" is that every other time you invoke it, you should get back exactly what was there originally.

There's probably an elegant way to solve it, but I haven't found it yet.

from textadept.

mierenhoop avatar mierenhoop commented on June 16, 2024

The one issue is if you start with a commented line and extend the selection to the line below, for example:

#foo
bar

When you toggle comment, you'll get this:

foo
ar

Toggling again gives you:

#foo
#ar

The idea of "toggle comment" is that every other time you invoke it, you should get back exactly what was there originally.

I can't reproduce the problem where toggling again doesn't restore the original.

Peek 2023-10-12 21-56

Just for comparison, vscode doesn't seem very smart about commenting either. It will often double comment lines which is even more annoying than having two different hotkeys.

This patch tries to replicate VSCode's behaviour where it will double comment, it's really just a matter of taste at this point :)

from textadept.

mierenhoop avatar mierenhoop commented on June 16, 2024

Ah, thanks for clarifying.

from textadept.

Related Issues (20)

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.