added openai bug fix

This commit is contained in:
MrStashley 2024-03-27 17:04:29 -07:00
parent 052645e0df
commit 24bba1305b
2 changed files with 14 additions and 9 deletions

View File

@ -113,19 +113,21 @@ class AIChat extends React.Component<{}, {}> {
mobx.action(() => {
this.isFocused.set(true);
})();
GlobalModel.inputModel.codeSelectDeselectAndClear();
}
onTextAreaBlur(e: any) {
mobx.action(() => {
this.isFocused.set(false);
})();
GlobalModel.inputModel.codeSelectDeselectAndClear();
}
onTextAreaChange(e: any) {
// set height of textarea based on number of newlines
mobx.action(() => {
this.textAreaNumLines.set(e.target.value.split(/\n/).length);
GlobalModel.inputModel.codeSelectDeselectAll();
GlobalModel.inputModel.codeSelectDeselectAndClear();
})();
}
@ -150,7 +152,7 @@ class AIChat extends React.Component<{}, {}> {
return;
}
currentRef.setRangeText("\n", currentRef.selectionStart, currentRef.selectionEnd, "end");
GlobalModel.inputModel.codeSelectDeselectAll();
GlobalModel.inputModel.codeSelectDeselectAndClear();
}
onArrowUpPressed(): boolean {
@ -160,7 +162,7 @@ class AIChat extends React.Component<{}, {}> {
}
if (this.getLinePos(currentRef).linePos > 1) {
// normal up arrow
GlobalModel.inputModel.codeSelectDeselectAll();
GlobalModel.inputModel.codeSelectDeselectAndClear();
return false;
}
GlobalModel.inputModel.codeSelectSelectNextOldestCodeBlock();

View File

@ -582,7 +582,7 @@ class InputModel {
}
let incBlockIndex = this.codeSelectSelectedIndex.get() + 1;
if (this.codeSelectSelectedIndex.get() == this.codeSelectBlockRefArray.length - 1) {
this.codeSelectDeselectAll();
this.codeSelectDeselectAndClear();
if (this.aiChatWindowRef?.current != null) {
this.aiChatWindowRef.current.scrollTop = this.aiChatWindowRef.current.scrollHeight;
}
@ -606,7 +606,7 @@ class InputModel {
}
let decBlockIndex = this.codeSelectSelectedIndex.get() - 1;
if (decBlockIndex < 0) {
this.codeSelectDeselectAll(this.codeSelectTop);
this.codeSelectDeselectAndClear(this.codeSelectTop);
if (this.aiChatWindowRef?.current != null) {
this.aiChatWindowRef.current.scrollTop = 0;
}
@ -629,16 +629,19 @@ class InputModel {
return blockIndex == this.codeSelectSelectedIndex.get();
}
codeSelectDeselectAll(direction: number = this.codeSelectBottom) {
if (this.codeSelectSelectedIndex.get() == direction) {
return;
}
codeSelectDeselectAndClear(direction: number = this.codeSelectBottom) {
mobx.action(() => {
this.codeSelectSelectedIndex.set(direction);
this.codeSelectBlockRefArray = [];
})();
}
codeSelectDeselectAll(direction: number = this.codeSelectBottom) {
mobx.action(() => {
this.codeSelectSelectedIndex.set(direction);
})();
}
openAIAssistantChat(): void {
mobx.action(() => {
this.aIChatShow.set(true);