Skip to content

Commit 1dbe571

Browse files
committed
应该使用最后一个有效行的缩进
1 parent a7a40a5 commit 1dbe571

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

script/core/fix-indent.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,19 @@ local function fixWrongIndent(state, change)
122122
local position = guide.positionOf(change.range.start.line, change.range.start.character)
123123
local row = guide.rowColOf(position)
124124
local myIndent = getIndent(state, row + 1)
125-
local lastIndent = getIndent(state, row)
126-
if #myIndent <= #lastIndent then
125+
local lastOffset = lookBackward.findAnyOffset(state.lua, guide.positionToOffset(state, position))
126+
if not lastOffset then
127127
return
128128
end
129-
if not util.stringStartWith(myIndent, lastIndent) then
129+
local lastPosition = guide.offsetToPosition(state, lastOffset)
130+
local lastRow = guide.rowColOf(lastPosition)
131+
local lastIndent = getIndent(state, lastRow)
132+
if #myIndent <= #lastIndent then
130133
return
131134
end
132-
local lastOffset = lookBackward.findAnyOffset(state.lua, guide.positionToOffset(state, position))
133-
if not lastOffset then
135+
if not util.stringStartWith(myIndent, lastIndent) then
134136
return
135137
end
136-
local lastPosition = guide.offsetToPosition(state, lastOffset)
137138
if isInBlock(state, lastPosition) then
138139
return
139140
end

0 commit comments

Comments
 (0)