Skip to content

Commit cef8703

Browse files
committed
feat: pad code on run for better diagnostics
1 parent 119ec35 commit cef8703

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lua/leetcode-ui/question.lua

+4-2
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,12 @@ function Question:range()
173173
return start_i, end_i, lines
174174
end
175175

176+
---@param submit boolean
176177
---@return string
177-
function Question:lines()
178+
function Question:lines(submit)
178179
local start_i, end_i, lines = self:range()
179-
return table.concat(lines, "\n", start_i, end_i)
180+
local prefix = not submit and ("\n"):rep(start_i - 1) or ""
181+
return prefix .. table.concat(lines, "\n", start_i, end_i)
180182
end
181183

182184
---@param self lc.ui.Question

lua/leetcode/runner/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function Runner:handle(submit)
3131

3232
local body = {
3333
lang = question.lang,
34-
typed_code = self.question:lines(),
34+
typed_code = self.question:lines(submit),
3535
question_id = question.q.id,
3636
data_input = not submit and table.concat(question.console.testcase:content(), "\n") or nil,
3737
}

0 commit comments

Comments
 (0)