Skip to content

Commit 4c73b16

Browse files
committed
编辑器 修复外部编辑
1 parent 800fc93 commit 4c73b16

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/renderer/editor/editor.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ class xeditor {
693693
* 写入编辑器
694694
* @param value 传入text
695695
*/
696-
push(value: string) {
696+
push(value: string, unwrite = false) {
697697
this.text.value = value;
698698
lineNum();
699699
setTextAreaHeight();
@@ -702,10 +702,8 @@ class xeditor {
702702
exitFind();
703703
}
704704

705-
if (editingOnOther) {
706-
editingOnOther = false;
705+
if (!unwrite) {
707706
writeEditOnOther();
708-
editingOnOther = true;
709707
}
710708

711709
if (isCheck) runSpellcheck();
@@ -1969,7 +1967,7 @@ function editOnOther() {
19691967
fileWatcher = fs.watch(tmpTextPath, () => {
19701968
fs.readFile(tmpTextPath, "utf8", (e, data) => {
19711969
if (e) console.log(e);
1972-
editor.push(data);
1970+
editor.push(data, true);
19731971
});
19741972
});
19751973
textOut.attr({ title: "正在外部编辑中,双击退出" });
@@ -1992,6 +1990,7 @@ function editOnOther() {
19921990
}
19931991

19941992
function writeEditOnOther() {
1993+
if (!editingOnOther) return;
19951994
const data = Buffer.from(editor.get());
19961995
fs.writeFile(tmpTextPath, data, () => {});
19971996
}

0 commit comments

Comments
 (0)