From 497c24ee1e9201be0aa93306028014de85948c1b Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Mon, 11 Nov 2024 23:13:26 +0800 Subject: [PATCH] Fix the bug that code can't get the selected text --- src/public/app/widgets/find.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/public/app/widgets/find.js b/src/public/app/widgets/find.js index 5e0258998..a68711a17 100644 --- a/src/public/app/widgets/find.js +++ b/src/public/app/widgets/find.js @@ -159,8 +159,13 @@ export default class FindWidget extends NoteContextAwareWidget { this.handler = await this.getHandler(); - const selectedText = window.getSelection().toString() || ""; - + let selectedText = ''; + if (this.note.type === 'code'){ + const codeEditor = await this.noteContext.getCodeEditor(); + selectedText = codeEditor.getSelection(); + }else{ + selectedText = window.getSelection().toString() || ""; + } this.$widget.show(); this.$input.focus(); const isReadOnly = await this.noteContext.isReadOnly();