intellij-elixir
intellij-elixir copied to clipboard
Comment with Line Comment with Indentation support
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() do
▮res = 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"];
+1
+1
@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.
Just a reminder that I have solved this issue 2 weeks ago in PR #3582