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

Commit afd8db2

Browse files
authored
Update revsecommoneditorbehavior.livecodescript
added testing for if tFirstLine is tLastLine, though the speed difference is not measurable, both version take 12 milliseconds on a 3600 line script. But I agree it is a cleaner way to do it. Additionally I changed put (the number of chars of line 1 to tFirstLine - 1 of tNewText) + 1 into tFirstLineChar from + 2 to +1. This also keeps the selection if the cursor is positioned before the first char. As far as I understand charIndex works only on fields not variables. I did test and there is not speed improvement using charIndex on the field.
1 parent d3b7dad commit afd8db2

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,20 +2998,28 @@ command scriptFormat pScope, pDontGroup
29982998
if word 4 of it is a number then put word 4 of it into tLastLine else put tFirstLine into tLastLine
29992999

30003000
put the number of chars of line 1 to tFirstLine of tOldText into tCharsAboveFirstLineOld
3001-
put the number of chars of line 1 to tLastLine of tOldText into tCharsAboveLastLineOld
3001+
if tFirstLine is tLastLine then
3002+
put tCharsAboveFirstLineOld into tCharsAboveLastLineOld
3003+
else
3004+
put the number of chars of line 1 to tLastLine of tOldText into tCharsAboveLastLineOld
3005+
end if
30023006

30033007
local tNewText
30043008
put textFormatSelection(tOldText) into tNewText
30053009

30063010
local tCharsAboveFirstLineNew, tCharsAboveLastLineNew, tDiffFirstLine, tDiffLastLine
30073011
put the number of chars of line 1 to tFirstLine of tNewText into tCharsAboveFirstLineNew
3008-
put the number of chars of line 1 to tLastLine of tNewText into tCharsAboveLastLineNew
3012+
if tFirstLine is tLastLine then
3013+
put tCharsAboveFirstLineNew into tCharsAboveLastLineNew
3014+
else
3015+
put the number of chars of line 1 to tLastLine of tNewText into tCharsAboveLastLineNew
3016+
end if
30093017

30103018
put tCharsAboveFirstLineOld - tCharsAboveFirstLineNew into tDiffFirstLine
30113019
put tCharsAboveLastLineOld - tCharsAboveLastLineNew into tDiffLastLine
30123020

30133021
local tFirstLineChar
3014-
put (the number of chars of line 1 to tFirstLine - 1 of tNewText) + 2 into tFirstLineChar
3022+
put (the number of chars of line 1 to tFirstLine - 1 of tNewText) + 1 into tFirstLineChar
30153023

30163024
textReplace tStartChar, tOldText, tNewText, empty, pDontGroup
30173025

0 commit comments

Comments
 (0)