Skip to content

fix: remove leading indentation from exercise files (#54)#99

Open
NicksPatties wants to merge 1 commit into
mainfrom
fix/remove-indentation
Open

fix: remove leading indentation from exercise files (#54)#99
NicksPatties wants to merge 1 commit into
mainfrom
fix/remove-indentation

Conversation

@NicksPatties

Copy link
Copy Markdown
Owner

Problem

Bug #54: Sources that start indented (like Go code files) forced users to type all the leading whitespace, defeating the auto-indent feature.

Root Cause

scanFileText() in cmd/root/sweet.go read file content and joined lines with newlines, but never stripped leading whitespace. DedentLines() already existed in the util package (used by the add command) but wasn't applied during exercise execution.

Fix

Added util.DedentLines(lines) call in scanFileText to remove the minimum common indentation from all lines before returning the exercise text.

Changes

  • cmd/root/sweet.go: Added util.DedentLines() call in scanFileText
  • cmd/root/sweet_test.go: Added 2 test cases for dedented output

Closes #54

scanFileText read file content but never stripped leading whitespace,
forcing users to type unnecessary spaces for indented language files
like Go. Added util.DedentLines call to strip minimum common
indentation.
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.

Remove indenting from sources that start indented

1 participant