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

Comment with Line Comment with Indentation support #2872

Open
rNoz opened this issue Sep 26, 2022 · 4 comments
Open

Comment with Line Comment with Indentation support #2872

rNoz opened this issue Sep 26, 2022 · 4 comments

Comments

@rNoz
Copy link

rNoz commented Sep 26, 2022

Greetings, KronicDeth.

Do you know how can I get an indented comment when using "Comment with Line Comment"? Any workaround?

I represent the different positions of the caret with (▮), using this command in each of those lines.

Having this situation:

def something() dores = func(x, y)
   with true <- should_work?(args),{:ok, result} <- impl().get(x) do
     result
   else
     _ -> nil
   end
end

After "Comment with Line Comment" in both positions, I would like to have:

def something() do
  # res = func(x, y)
  with true <- should_work?(args),
       # {:ok, result} <- impl().get(x) do
    result
  else
    _ -> nil
  end
end

Instead of the current behaviour:

def something() do
#   res = func(x, y)
  with true <- should_work?(args),
#        {:ok, result} <- impl().get(x) do
    result
  else
    _ -> nil
  end
end

The current behaviour is just placing # at the beginning of the line. However, I would like to mimic the behaviour seeing in other languages (like JavaScript), where the comment is placed at the beginning of the text of the current line, with just an empty space after it # (eg. line ␣␣␣␣{:err, _msg} <- func() should be commented ␣␣␣␣#␣{:err, _msg} <- func(), not #␣␣␣␣{:err, _msg} <- func()).

How hard would be to achieve that? If you direct me on how to approach it I can study it, try to achieve it and do a PR at some point.

In JavaScript there is also another behaviour added (that is great): if the previous line is commented, the current one to be commented "inherits" the same indentation level as the previous one:

      window.cancelAnimationFrame =
       window[vendors[x] + "CancelAnimationFrame"] ||
        window[vendors[x] + "CancelRequestAnimationFrame"];
        
     window.cancelAnimationFrame =
        window[vendors[x] + "CancelAnimationFrame"] ||
        window[vendors[x] + "CancelRequestAnimationFrame"];

"Comment with Line Comment":

      window.cancelAnimationFrame =
        // window[vendors[x] + "CancelAnimationFrame"] ||
       window[vendors[x] + "CancelRequestAnimationFrame"];
        
      // window.cancelAnimationFrame =
       window[vendors[x] + "CancelAnimationFrame"] ||
        window[vendors[x] + "CancelRequestAnimationFrame"];

"Comment with Line Comment" (again):

      window.cancelAnimationFrame =
        // window[vendors[x] + "CancelAnimationFrame"] ||
        // window[vendors[x] + "CancelRequestAnimationFrame"];
        
      // window.cancelAnimationFrame =
      //    window[vendors[x] + "CancelAnimationFrame"] ||
        window[vendors[x] + "CancelRequestAnimationFrame"];
@rNoz rNoz changed the title Comment line indented Comment with Line Comment with Indentation support Sep 26, 2022
@nichita-pasecinic
Copy link

+1

@OuDale
Copy link

OuDale commented Nov 28, 2022

+1

@rNoz
Copy link
Author

rNoz commented Feb 10, 2024

@KronicDeth As a side-side-side project, I can try to implement this along 2024, however, since I have never dealt with jetbrain's plugins/code and this specific functionality, could you provide me some direction to narrow my efforts to achieve this? e.g. which files to focus, if you are aware of a functionality (maybe in this plugin or in other) that address code-modifications that can be close to what I would require here, etc. anything will be welcomed.

@rNoz
Copy link
Author

rNoz commented May 17, 2024

Just a reminder that I have solved this issue 2 weeks ago in PR #3582

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

No branches or pull requests

4 participants