Skip to content

Commit

Permalink
SALTO-1244 - Keep trailing whitespace in multiline strings (#1965)
Browse files Browse the repository at this point in the history
  • Loading branch information
netama authored Apr 1, 2021
1 parent 91e8c85 commit 16d8f07
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ const createTemplateExpressions = (

const trimToken = (token: Required<Token>): Required<Token> => ({
...token,
text: trimEnd(token.text),
value: trimEnd(token.value),
text: trimEnd(token.text, '\r\n'),
value: trimEnd(token.value, '\r\n'),
})

const createStringValue = (
Expand Down
13 changes: 11 additions & 2 deletions packages/workspace/test/parser/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,15 @@ each([true, false]).describe('Salto parser', (useLegacyParser: boolean) => {
withSpaces = '''
Give me some
OK?
'''
withTrailingNewline = '''
This has
a trailing line with spaces
'''
withQuotes = '''
"I can see Russia from my house!"
'''
'''
}
type salesforce.stringAttr {
Expand Down Expand Up @@ -624,10 +629,14 @@ each([true, false]).describe('Salto parser', (useLegacyParser: boolean) => {
expect(multilineObject.annotations).toHaveProperty('data')
expect(multilineObject.annotations.data).toEqual(' This\n is\n Multiline')
})
it('should preserve end of line spaces', () => {
it('should preserve end of line spaces without inserting a newline', () => {
expect(multilineObject.annotations).toHaveProperty('withSpaces')
expect(multilineObject.annotations.withSpaces).toEqual(' Give me some \n OK?')
})
it('should preserve end of line spaces on new line', () => {
expect(multilineObject.annotations).toHaveProperty('withTrailingNewline')
expect(multilineObject.annotations.withTrailingNewline).toEqual(' This has \n a trailing line with spaces\n ')
})
it('should handle qoutation marks inside the multiline string', () => {
expect(multilineObject.annotations).toHaveProperty('withQuotes')
expect(multilineObject.annotations.withQuotes).toEqual(' "I can see Russia from my house!"')
Expand Down

0 comments on commit 16d8f07

Please sign in to comment.