Skip to content

Commit f5c4e67

Browse files
committed
还原代码
1 parent 4b4d768 commit f5c4e67

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

script/core/code-action.lua

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,51 @@ local function solveAwaitInSync(uri, diag, results)
350350
}
351351
end
352352

353+
local function solveSpell(uri, diag, results)
354+
local spell = require 'provider.spell'
355+
local word = diag.data
356+
if word == nil then
357+
return
358+
end
359+
360+
results[#results+1] = {
361+
title = lang.script('ACTION_ADD_DICT', word),
362+
kind = 'quickfix',
363+
command = {
364+
title = lang.script.COMMAND_ADD_DICT,
365+
command = 'lua.setConfig',
366+
arguments = {
367+
{
368+
key = 'Lua.spell.dict',
369+
action = 'add',
370+
value = word,
371+
uri = uri,
372+
}
373+
}
374+
}
375+
}
376+
377+
local suggests = spell.getSpellSuggest(word)
378+
for _, suggest in ipairs(suggests) do
379+
results[#results+1] = {
380+
title = suggest,
381+
kind = 'quickfix',
382+
edit = {
383+
changes = {
384+
[uri] = {
385+
{
386+
start = converter.unpackPosition(uri, diag.range.start),
387+
finish = converter.unpackPosition(uri, diag.range["end"]),
388+
newText = suggest
389+
}
390+
}
391+
}
392+
}
393+
}
394+
end
395+
396+
end
397+
353398
local function solveDiagnostic(uri, diag, start, results)
354399
if diag.source == lang.script.DIAG_SYNTAX_CHECK then
355400
solveSyntax(uri, diag, results)
@@ -370,6 +415,8 @@ local function solveDiagnostic(uri, diag, start, results)
370415
solveTrailingSpace(uri, diag, results)
371416
elseif diag.code == 'await-in-sync' then
372417
solveAwaitInSync(uri, diag, results)
418+
elseif diag.code == 'spell-check' then
419+
solveSpell(uri, diag, results)
373420
end
374421
disableDiagnostic(uri, diag.code, start, results)
375422
end

script/proto/define.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ m.DiagnosticDefaultSeverity = {
6161
['duplicate-doc-field'] = 'Warning',
6262
['unknown-diag-code'] = 'Warning',
6363

64-
['codestyle-check'] = "Warning",
64+
['codestyle-check'] = 'Warning',
65+
['spell-check'] = 'Information',
6566
}
6667

6768
---@alias DiagnosticDefaultNeededFileStatus
@@ -123,6 +124,7 @@ m.DiagnosticDefaultNeededFileStatus = {
123124
['unknown-diag-code'] = 'Any',
124125

125126
['codestyle-check'] = 'None',
127+
['spell-check'] = 'None',
126128
}
127129

128130
--- 诊断报告标签

0 commit comments

Comments
 (0)