mirror of
https://github.com/turboderp-org/exui.git
synced 2026-04-20 14:29:52 +00:00
Prevent generating with no context,
This commit is contained in:
@@ -417,14 +417,16 @@ class NotepadView {
|
||||
generateToken() {
|
||||
if (!globals.g.loadedModelUUID) return;
|
||||
|
||||
this.generateButton.setEnabled(false, 200);
|
||||
this.generateTokenButton.setEnabled(false, 200);
|
||||
this.editor.disabled = true;
|
||||
|
||||
let pos = this.editor.selectionStart;
|
||||
let end = this.editor.selectionEnd;
|
||||
let text = this.editor.value;
|
||||
|
||||
if (pos == 0) return;
|
||||
|
||||
this.generateButton.setEnabled(false, 200);
|
||||
this.generateTokenButton.setEnabled(false, 200);
|
||||
this.editor.disabled = true;
|
||||
|
||||
if (end > pos) {
|
||||
this.editor.value = this.editor.value.slice(0, pos) + this.editor.value.slice(end);
|
||||
}
|
||||
@@ -455,6 +457,12 @@ class NotepadView {
|
||||
generate() {
|
||||
if (!globals.g.loadedModelUUID) return;
|
||||
|
||||
let pos = this.editor.selectionStart;
|
||||
let end = this.editor.selectionEnd;
|
||||
let text = this.editor.value;
|
||||
|
||||
if (pos == 0) return;
|
||||
|
||||
this.generateButton.setEnabled(false);
|
||||
this.generateButton.setVisible(false);
|
||||
this.cancelButton.setEnabled(true);
|
||||
@@ -462,10 +470,6 @@ class NotepadView {
|
||||
this.generateTokenButton.setEnabled(false);
|
||||
this.editor.disabled = true;
|
||||
|
||||
let pos = this.editor.selectionStart;
|
||||
let end = this.editor.selectionEnd;
|
||||
let text = this.editor.value;
|
||||
|
||||
if (end > pos) {
|
||||
this.editor.value = this.editor.value.slice(0, pos) + this.editor.value.slice(end);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user