Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add edit words suggestion #2658

Merged
merged 5 commits into from
Dec 16, 2023
Merged
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
Prev Previous commit
feat: add lazy invoke
Signed-off-by: licho <lecho.sun@gmail.com>
  • Loading branch information
leechor committed Dec 16, 2023
commit 260f8dcd914f8749cd2a51eb65acea2707005116
9 changes: 9 additions & 0 deletions dinky-web/src/components/CustomEditor/CodeEdit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,16 @@ const CodeEdit = (props: CodeEditFormProps & connect) => {
editorInstance.current = editor;
monacoInstance.current = monacoIns;

let timeoutId: NodeJS.Timeout | null = null;
editor.onDidChangeModelContent((e) => {
if (timeoutId !== null) {
return;
}

timeoutId = setTimeout(() => {
timeoutId = null;
}, 3000);

const model = editor.getModel();
if (model) {
const segmenter = new Intl.Segmenter('en', { granularity: 'word' });
Expand Down