-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { Uri } from 'vscode'; | ||
|
||
import * as di from '../di.js'; | ||
|
||
export async function traceWord(word: string, uri: Uri | string, _width: number): Promise<string> { | ||
const client = di.get('client'); | ||
const result = await client.serverApi.traceWord({ word, uri: uri.toString() }); | ||
|
||
if (!result) { | ||
return 'No trace results'; | ||
} | ||
|
||
const lines: string[] = []; | ||
|
||
lines.push(`Trace: "${result.word}"`); | ||
|
||
if (result.errors) { | ||
lines.push('Errors:'); | ||
lines.push(` ${result.errors}`); | ||
} | ||
|
||
for (const trace of result.traces || []) { | ||
lines.push(`${trace.word}: ${trace.found ? 'found' : 'not found'}`); | ||
for (const line of trace.traces) { | ||
const w = line.foundWord || line.word; | ||
lines.push(`${w} ${line.dictName} ${line.found ? 'found' : 'not found'}`); | ||
} | ||
} | ||
|
||
return lines.join('\n'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters