From 08dba490f4329cdef5becc55b85fbca147c43535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BD=A6=E5=8D=97?= Date: Tue, 14 May 2024 11:38:48 +0800 Subject: [PATCH] refore: retain selectedText --- src/shared/editorSetCode.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/shared/editorSetCode.ts diff --git a/src/shared/editorSetCode.ts b/src/shared/editorSetCode.ts new file mode 100644 index 0000000..8df30c6 --- /dev/null +++ b/src/shared/editorSetCode.ts @@ -0,0 +1,19 @@ +/* + * @Author: ZtrainWilliams ztrain1224@163.com + * @Date: 2023-08-18 13:44:10 + * @Description: + */ +const vscode = require('vscode'); + +export const getPreviousEditorText = () => { + let activeEditor = vscode.window.activeTextEditor; + let previousEditor = activeEditor.document._savedDecorations[activeEditor.document._savedDecorations.length - 2]; + // let previousFileUri = previousEditor.document.uri; + + let selection = previousEditor.selection; + let selectedText = previousEditor.document.getText(selection); + console.log(previousEditor, selectedText); + return selectedText; +}; + +// do something with previousFileUri and selectedText