rewrite() in utils.js only preserves formatting when using spaces - fails when using tabs in editor #55

Closed
js1972 opened this Issue Feb 21, 2014 · 6 comments

Projects

None yet

2 participants

@js1972
Collaborator

The logic used to prefix the splicable with spaces needs to account for the fact that the index.html might be written using tabs instead of spaces.
It just so happens that our classical app generator has an index.html that still uses space instead of tabs.

@js1972 js1972 added the bug label Feb 21, 2014
@js1972 js1972 self-assigned this Feb 21, 2014
@js1972 js1972 added a commit to js1972/generator-openui5 that referenced this issue Feb 21, 2014
@js1972 js1972 feat(Components): Handle component namespaces
Handle component namespaces:
 - Prompt for application architecture in uiComponent generator (will be refactored to be automatic later)
 - If application.js style then use addLocalResource()
 - If Component style then use new function: addResourceRoot() (this is still a work in progress for formatting the index.html)
 - Fix issue that the rewrite function in utils.js doesn't handle files that use tabs instead of spaces

Fixes #47 #54 #55
793a582
@saschakiefer

I copied your coding from your commit, but it doesn't seem to work. Maybe you can check that again.

@js1972
Collaborator
@saschakiefer

Yeah, I pushed everything. It's just the indents that seems to have issues. Maybe I get a chance to debug it today or tomorrow. I'll let you know if I find sth. out.

@js1972
Collaborator

As can be seen here - if the index.html uses all spaces or all tabs and not mixed whitespace the formatting is correct.:
image

Now just need to enhance the logic with options to increase the indent and add a comma to the previous line...

@js1972 js1972 added a commit to js1972/generator-openui5 that referenced this issue Feb 23, 2014
@js1972 js1972 fix(file rewrite): fix file re-write capability.
- Fix formatting for html template files to be all tabs for whitespace (some spaces had crept in) which stuffs up the formatting of file rewriting.

- Added an args option to the rewrite() function to specify extra indents.

fix #55
a84d491
@js1972
Collaborator

Think of a good way to test this re-write functionality. Probably easiest to use a dummy index.html file and add the test to the sub-generators...

@saschakiefer

That's what I planned anyways ;-) But more on the "is the content there" level. Not sure about the formatting...

@saschakiefer saschakiefer added this to the 0.2.1 milestone Feb 23, 2014
@js1972 js1972 added a commit to js1972/generator-openui5 that referenced this issue Feb 24, 2014
@js1972 js1972 fix(rewrite): Handle formatting of json comments when adding new reso…
…urce roots

Add new method addCommaToLine(args) which allows you to find a line in a file
 and add a terminating comment char at a specified offset from that line. Uses
 same methods as in rewrite(args).

Fixes #55 #57
1662629
@js1972 js1972 added a commit to js1972/generator-openui5 that referenced this issue Feb 24, 2014
@js1972 js1972 refactor(sub-gen): Refactor error handling when writing resource root…
…s from the component sub-generator

Fixes #54 #55
fd8402e
@js1972 js1972 closed this Feb 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment