Skip to content

Commit

Permalink
fix: [inline chat] After the code is generated, the editor view scrolled
Browse files Browse the repository at this point in the history
as title

Log: fix issue
  • Loading branch information
Kakueeen authored and deepin-mozart committed Oct 30, 2024
1 parent 0ca1a32 commit e5c66ac
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/plugins/codeeditor/gui/texteditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,21 +645,16 @@ int TextEditor::positionFromPoint(int x, int y)

void TextEditor::replaceRange(int lineFrom, int indexFrom, int lineTo, int indexTo, const QString &text)
{
SendScintilla(SCI_CLEARSELECTIONS);

setSelection(lineFrom, indexFrom, lineTo, indexTo);
replaceSelectedText(text);
int startPos = positionFromLineIndex(lineFrom, indexFrom);
int endPos = positionFromLineIndex(lineTo, indexTo);
replaceRange(startPos, endPos, text);
}

void TextEditor::replaceRange(int startPosition, int endPosition, const QString &text)
{
int startLine = 0, startIndex = 0;
int endLine = 0, endIndex = 0;

lineIndexFromPosition(startPosition, &startLine, &startIndex);
lineIndexFromPosition(endPosition, &endLine, &endIndex);

replaceRange(startLine, startIndex, endLine, endIndex, text);
SendScintilla(SCI_SETTARGETSTART, startPosition);
SendScintilla(SCI_SETTARGETEND, endPosition);
SendScintilla(SCI_REPLACETARGET, -1, textAsBytes(text).constData());
}

void TextEditor::insertText(const QString &text)
Expand Down

0 comments on commit e5c66ac

Please sign in to comment.