Skip to content

Commit

Permalink
应该使用最后一个有效行的缩进
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Aug 6, 2024
1 parent a7a40a5 commit 1dbe571
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions script/core/fix-indent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,19 @@ local function fixWrongIndent(state, change)
local position = guide.positionOf(change.range.start.line, change.range.start.character)
local row = guide.rowColOf(position)
local myIndent = getIndent(state, row + 1)
local lastIndent = getIndent(state, row)
if #myIndent <= #lastIndent then
local lastOffset = lookBackward.findAnyOffset(state.lua, guide.positionToOffset(state, position))
if not lastOffset then
return
end
if not util.stringStartWith(myIndent, lastIndent) then
local lastPosition = guide.offsetToPosition(state, lastOffset)
local lastRow = guide.rowColOf(lastPosition)
local lastIndent = getIndent(state, lastRow)
if #myIndent <= #lastIndent then
return
end
local lastOffset = lookBackward.findAnyOffset(state.lua, guide.positionToOffset(state, position))
if not lastOffset then
if not util.stringStartWith(myIndent, lastIndent) then
return
end
local lastPosition = guide.offsetToPosition(state, lastOffset)
if isInBlock(state, lastPosition) then
return
end
Expand Down

0 comments on commit 1dbe571

Please sign in to comment.