Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 55dc399

Browse files
author
Monte Goulding
authored
Merge pull request #1971 from bwmilby/bwm-bugfix-21245
[[ Bug 21245 ]] SE indent errors with inline block comments
2 parents 46297e0 + 6373c36 commit 55dc399

3 files changed

Lines changed: 40 additions & 9 deletions

File tree

Toolset/palettes/script editor/behaviors/revsecommoneditorbehavior.livecodescript

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ end __GetPreference
334334

335335
-- Text Formatting Code
336336
command textFormatInitialize
337-
-- permit use in environment witn no dependencies
337+
-- permit use in environment with no dependencies
338338
local tTabDepth
339339
put __GetPreference("editor,tabdepth", 3) into tTabDepth
340340

@@ -2621,35 +2621,55 @@ end dragEnd
26212621

26222622
# Description
26232623
## Returns a line stripped of comments at the end of the line
2624+
## and inline comments ( /* ... */ )
26242625
private function lineStripComments pLine
2625-
local tLine
2626+
local tLine, tInComment
26262627
split pLine by quote
26272628

2629+
put false into tInComment
26282630
repeat with tIndex = 1 to the number of elements of pLine step 2
2629-
local tDecommented
2630-
put __StripComment(pLine[tIndex]) into tDecommented
2631-
put tDecommented after tLine
2632-
if pLine[tIndex] is tDecommented and \
2633-
tIndex is not the number of elements of pLine then
2631+
put __StripComment(pLine[tIndex], tInComment) after tLine
2632+
if tInComment then exit repeat
2633+
if tIndex is not the number of elements of pLine then
26342634
put quote & pLine[tIndex+1] & quote after tLine
26352635
end if
26362636
end repeat
26372637

26382638
return tLine
26392639
end lineStripComments
26402640

2641-
private function __StripComment pLine
2641+
private function __StripComment pLine, @xInComment
26422642
local tOffset
2643-
repeat for each word tComment in "# -- // /*"
2643+
repeat for each word tComment in "# -- //"
26442644
put offset(tComment, pLine) into tOffset
26452645
if tOffset is not 0 then
26462646
delete char tOffset to -1 of pLine
2647+
put true into xInComment
26472648
end if
26482649
end repeat
2650+
2651+
put __StripBlockComment(pLine, xInComment) into pLine
26492652

26502653
return pLine
26512654
end __StripComment
26522655

2656+
private function __StripBlockComment pline, @xInComment
2657+
local tOffset, tOffsetEnd
2658+
put offset("/*", pLine) into tOffset
2659+
if tOffset is not 0 then
2660+
put offset("*/", pLine, tOffset) into tOffsetEnd
2661+
if tOffsetEnd is not 0 then
2662+
delete char tOffset to tOffset + tOffsetEnd of pLine
2663+
put __StripBlockComment(pLine, xInComment) into pLine
2664+
else
2665+
delete char tOffset to -1 of pLine
2666+
put true into xInComment
2667+
end if
2668+
end if
2669+
2670+
return pLine
2671+
end __StripBlockComment
2672+
26532673
################################################################################
26542674

26552675
command actionCopy

notes/bugfix-21245.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# SE indent errors with inline block comments and line continuation
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
command inlineCommentTest \
2+
pBasePath, /* base path for export folders */ \
3+
@xRelativePath /* relative path for folder */
4+
-- code
5+
end inlineCommentTest
6+
7+
command quoteAfterCommentTest
8+
put "test" -- "extra" \
9+
put "test"
10+
end quoteAfterCommentTest

0 commit comments

Comments
 (0)