Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: submit hook for capture both successful, failed submissions
  • Loading branch information
jingyi-zhao-01 committed Sep 23, 2025
commit 6a59fe42ed74dc0f35d1c62fca2dd50c11df57c8
4 changes: 4 additions & 0 deletions lua/leetcode/config/template.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
---| "enter"
---| "question_enter"
---| "leave"
---| "submit"

---@alias lc.size
---| string
Expand Down Expand Up @@ -120,6 +121,9 @@ local M = {

---@type fun()[]
["leave"] = {},

---@type fun(question: lc.ui.Question, buffer: string, status_msg: string|nil, success: string|nil)[]
["submit"] = {},
},

keys = {
Expand Down
2 changes: 2 additions & 0 deletions lua/leetcode/runner/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local log = require("leetcode.logger")
local interpreter = require("leetcode.api.interpreter")
local config = require("leetcode.config")
local Judge = require("leetcode.logger.spinner.judge")
local utils = require("leetcode.utils")

---@type Path
local leetbody = config.storage.cache:joinpath("body")
Expand Down Expand Up @@ -52,6 +53,7 @@ function Runner:handle(submit)
end

if item then
utils.exec_hooks("submit", question, body.typed_code, item.status_msg, item._.success)
if item._.success then
judge:success(item.status_msg)
else
Expand Down