A Neovim plugin enabling you to solve LeetCode problems.
fix(picker): filtering
4 files changed, +16 -20
+4-6README.md
| @@ -365,15 +365,13 @@ https://github.com/kawre/leetcode.nvim/assets/69250723/b7be8b95-5e2c-4153-8845-4 | ||
| 365 | 365 | |
| 366 | 366 | ```lua |
| 367 | 367 | local leet_arg = "leetcode.nvim" |
| 368 | + ``` | |
| 368 | 369 | |
| 369 | - return { | |
| 370 | + ```lua | |
| 371 | + { | |
| 370 | 372 | "kawre/leetcode.nvim", |
| 371 | - ... | |
| 372 | 373 | lazy = leet_arg ~= vim.fn.argv()[1], |
| 373 | - opts = { | |
| 374 | - arg = leet_arg, | |
| 375 | - }, | |
| 376 | - ... | |
| 374 | + opts = { arg = leet_arg }, | |
| 377 | 375 | } |
| 378 | 376 | ``` |
| 379 | 377 |
+4-6README.zh.md
| @@ -367,15 +367,13 @@ https://github.com/kawre/leetcode.nvim/assets/69250723/b7be8b95-5e2c-4153-8845-4 | ||
| 367 | 367 | |
| 368 | 368 | ```lua |
| 369 | 369 | local leet_arg = "leetcode.nvim" |
| 370 | + ``` | |
| 370 | 371 | |
| 371 | - return { | |
| 372 | + ```lua | |
| 373 | + { | |
| 372 | 374 | "kawre/leetcode.nvim", |
| 373 | - ... | |
| 374 | 375 | lazy = leet_arg ~= vim.fn.argv()[1], |
| 375 | - opts = { | |
| 376 | - arg = leet_arg, | |
| 377 | - }, | |
| 378 | - ... | |
| 376 | + opts = { arg = leet_arg }, | |
| 379 | 377 | } |
| 380 | 378 | ``` |
| 381 | 379 |
+1-1lua/leetcode-ui/popup/console/testcase.lua
| @@ -4,7 +4,7 @@ local ConsolePopup = require("leetcode-ui.popup.console") | ||
| 4 | 4 | local t = require("leetcode.translator") |
| 5 | 5 | |
| 6 | 6 | ---@class lc.ui.Console.TestcasePopup : lc.ui.Console.Popup |
| 7 | ----@field testcases table<string[][]> | |
| 7 | +---@field testcases table<string[]> | |
| 8 | 8 | ---@field extmarks integer[] |
| 9 | 9 | local Testcase = ConsolePopup:extend("LeetTestcasePopup") |
| 10 | 10 |
+7-7lua/leetcode/pickers/question.lua
| @@ -104,17 +104,17 @@ local function filter_questions(questions, opts) | ||
| 104 | 104 | |
| 105 | 105 | ---@param q lc.cache.Question |
| 106 | 106 | return vim.tbl_filter(function(q) |
| 107 | - local flag = true | |
| 108 | - if opts.difficulty then | |
| 109 | - if not vim.tbl_contains(opts.difficulty, q.difficulty:lower()) then return false end | |
| 107 | + local diff_flag = true | |
| 108 | + if opts.difficulty and not vim.tbl_contains(opts.difficulty, q.difficulty:lower()) then | |
| 109 | + diff_flag = false | |
| 110 | 110 | end |
| 111 | 111 | |
| 112 | - if opts.status then | |
| 113 | - if not q.status then return true end | |
| 114 | - if not vim.tbl_contains(opts.status, q.status) then return false end | |
| 112 | + local status_flag = true | |
| 113 | + if opts.status and not vim.tbl_contains(opts.status, q.status) then -- | |
| 114 | + status_flag = false | |
| 115 | 115 | end |
| 116 | 116 | |
| 117 | - return true | |
| 117 | + return diff_flag and status_flag | |
| 118 | 118 | end, questions) |
| 119 | 119 | end |
| 120 | 120 |