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

continue-comment: avoid continue comment for shebangs #12663

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TornaxO7
Copy link
Contributor

@TornaxO7 TornaxO7 commented Jan 24, 2025

Closes #12423

Is an integration test wanted here?

Comment on lines 3554 to 3569
let continue_comment_tokens = {
static SHEBANG_REGEX: Lazy<Regex> =
Lazy::new(|| Regex::new(&["^", SHEBANG].concat()).unwrap());

let curr_line_num = selection.primary().cursor_line(text);
let line = text.line(curr_line_num);

let is_not_shebang = curr_line_num > 0
|| line
.as_str()
.map(|line| SHEBANG_REGEX.captures(line).is_some())
.unwrap_or(false);

if is_not_shebang
&& comment_continuation == CommentContinuation::Enabled
&& config.continue_comments
Copy link
Contributor Author

@TornaxO7 TornaxO7 Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit unsure about this part of the code. Is it fine if I move that into a private function within this module?

@nik-rev
Copy link
Contributor

nik-rev commented Jan 26, 2025

I found a bug

If you have this test:

#!/b#(|i)#n/bash

echo "Hello, World!"
echo "Current date and t#[|i]#ime: n$(date)"

hitting Enter will continue comment on the first line

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

Successfully merging this pull request may close these issues.

Auto comment continuation also happens with shebangs
2 participants