退出时保存光标位置

This commit is contained in:
fofolee
2022-04-13 16:49:47 +08:00
parent 8f479fa545
commit d659fdcc88
10 changed files with 27 additions and 23 deletions

View File

@@ -209,22 +209,20 @@ export default {
created() {},
methods: {
init() {
window.commandEditor = this;
let quickCommandInfo =
this.action.type === "run"
this.action.type !== "edit"
? this.$utools.getDB(this.$utools.DBPRE.CFG + "preferences")
?.codeHistory
?.codeHistory[this.action.type]
: this.action.data;
_.merge(this.quickcommandInfo, quickCommandInfo);
// monaco 相关
this.$refs.editor.setEditorValue(this.quickcommandInfo.cmd);
this.setLanguage(this.quickcommandInfo.program);
this.$refs.editor.setCursorPosition(this.quickcommandInfo.cursorPosition)
// 默认命令不可编辑
if (this.quickcommandInfo.tags?.includes("默认") && !utools.isDev()) {
this.canCommandSave = false;
}
if (this.action.type === "run")
this.$profile.codeHistory = this.quickcommandInfo;
},
programChanged(value) {
this.setLanguage(value);

View File

@@ -67,9 +67,6 @@ export default {
*/
action: Object,
},
mounted() {
window.runResult = this;
},
computed: {
fromUtools() {
return this.action.type === "input";

View File

@@ -275,9 +275,6 @@ export default {
quickcommandInfo: Object,
canCommandSave: Boolean,
},
mounted() {
window.CommandSideBar = this;
},
computed: {
specialVarsOptions() {
let x = Object.values(specialVars).filter(

View File

@@ -213,9 +213,6 @@ export default {
return this.configurationPage.activatedQuickCommandFeatureCodes.length;
},
},
mounted() {
window.configurationMenu = this;
},
props: {
isTagStared: Boolean,
currentTag: String,

View File

@@ -176,6 +176,13 @@ export default {
setEditorLanguage(language) {
monaco.editor.setModelLanguage(this.rawEditor.getModel(), language);
},
getCursorPosition() {
return this.rawEditor.getPosition();
},
setCursorPosition(pos) {
if (!pos) return;
this.rawEditor.setPosition(pos);
},
repacleEditorSelection(text) {
var selection = this.rawEditor.getSelection();
var range = new monaco.Range(

View File

@@ -76,7 +76,6 @@ export default {
};
},
mounted() {
window.SelectList = this;
window.temporaryStore.updateSelectList = (opt, id) => {
if (typeof id === "undefined") this.items.push(opt);
else this.items[id] = opt;