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

Fix rtrimLines function and improve comment removal #14

Merged
merged 2 commits into from
Jul 27, 2024

Conversation

yamadashy
Copy link
Owner

@yamadashy yamadashy commented Jul 27, 2024

This PR fixes two issues:

  1. rtrimLines now preserves newlines and empty lines.
  2. Comment removal now correctly handles # comments.

related: #2

Changes

// In src/utils/fileManipulator.ts
function rtrimLines(content: string): string {
-  return content.replace(/\s+$/gm, '');
+  return content.replace(/[ \t]+$/gm, '');
}

// In relevant comment removal functions
- content.replace(/\/\/.*|\/\*[\s\S]*?\*\//g, '');
+ content.replace(/\/\/.*|\/\*[\s\S]*?\*\/|#.*/g, '');

@yamadashy yamadashy force-pushed the fix/python-comment-remove branch from baf6ac5 to 5248a9f Compare July 27, 2024 05:22
@yamadashy yamadashy merged commit 37efdfd into main Jul 27, 2024
10 checks passed
@yamadashy yamadashy deleted the fix/python-comment-remove branch July 27, 2024 05:24
@yamadashy yamadashy mentioned this pull request Jul 27, 2024
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.

1 participant