rokucommunity / rokucommunity/brighterscript-formatter

BrighterScript template strings in single line if breaks indentations

Open
#31 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
17
Forks
10
Avg merge
49m
Merged PRs (30d)
7

Description

Here is an example of the code I had:

sub isScreenInStack(screenType as String)
	for each screen in SgNode.getAllChildren(m.screensNode)
		if lCase(screen.subType()) = `${lCase(screenType)}screen` then return true
	end for
	return false
end sub

And this is the resulting format after formatting:

sub isScreenInStack(screenType as String)
	for each screen in SgNode.getAllChildren(m.screensNode)
		if lCase(screen.subType()) = `${lCase(screenType)}screen` then return true
		end for
		return false
	end sub

If I change this to multi line like so then everything is fine again:

sub isScreenInStack(screenType as String)
	for each screen in SgNode.getAllChildren(m.screensNode)
		if lCase(screen.subType()) = `${lCase(screenType)}screen` then
			return true
		end if
	end for
	return false
end sub

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the formatter output with the single-line BrighterScript example shown in the issue, then trace how the formatter handles that construct alongside template-string expressions. Done means the single-line form keeps end for, return false, and end sub at their original indentation, while the multiline form remains correctly formatted.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.