diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2024-08-19 15:13:50 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2024-08-19 15:13:50 +0800 |
commit | 694721b0630ed581d3084075cf5f7433c5b8cf9e (patch) | |
tree | 65cf8f10a07a19ecd35c1704179fed3f7649ca81 | |
parent | f02a14597a0a689ef809f78c7baea4ae492910b7 (diff) | |
download | lua-language-server-694721b0630ed581d3084075cf5f7433c5b8cf9e.zip |
fix incorrect indent fixing for `for`
fix #2799
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/fix-indent.lua | 4 | ||||
-rw-r--r-- | script/parser/compile.lua | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/changelog.md b/changelog.md index 13aa482b..19ac35a5 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,7 @@ * `NEW` When using `enum["<key>" or <index>]`, undefined fields will raise an 'undefined' error. * `FIX` Renaming files in the directory leads to the auto-correction in "require" adding extra characters. * `FIX` Performance issue +* `FIX` Fix incorrect indent fixing for `for` ## 3.10.4 `2024-8-16` diff --git a/script/core/fix-indent.lua b/script/core/fix-indent.lua index 0b4b6985..11ff1629 100644 --- a/script/core/fix-indent.lua +++ b/script/core/fix-indent.lua @@ -105,8 +105,8 @@ local function fixWrongIndent(uri, change) if not util.stringStartWith(myIndent, lastIndent) then return end - local myBlock = getBlock(state, position) - if myBlock.bstart >= lastOffset then + local myBlock = getBlock(state, lastPosition) + if myBlock.bstart >= lastPosition then return end diff --git a/script/parser/compile.lua b/script/parser/compile.lua index 623a8c2c..597c0e5b 100644 --- a/script/parser/compile.lua +++ b/script/parser/compile.lua @@ -3664,7 +3664,7 @@ local function parseFor() or doToken == 'then' then local left = getPosition(Tokens[Index], 'left') local right = getPosition(Tokens[Index] + #doToken - 1, 'right') - action.finish = left + action.finish = right action.bstart = action.finish action.keyword[#action.keyword+1] = left action.keyword[#action.keyword+1] = right |