Skip to content

Commit

Permalink
fix: new term not showing in the right position
Browse files Browse the repository at this point in the history
fix the bug that new term not showing right after the old one after
the splitting
  • Loading branch information
hualet committed Aug 28, 2024
1 parent ef451de commit 7dc5ab4
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/views/termwidgetpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,20 @@ void TermWidgetPage::split(Qt::Orientation orientation)
TermWidget *term = m_currentTerm;

QSplitter *splitter = qobject_cast<QSplitter *>(term->parent());
int index = splitter ? splitter->indexOf(term) : m_layout->indexOf(term);

// if there's already a splitter, and the orientation is correct,
// just add a new term to the splitter.
if (splitter && splitter->orientation() != orientation) {
TermProperties properties(term->workingDirectory());
TermWidget *newTerm = createTerm(properties);
splitter->addWidget(newTerm);
splitter->insertWidget(index+1, newTerm); // insert after the current term
setSplitStyle(splitter);
setCurrentTerminal(newTerm);
} else {
// if there's no splitter, or the orientation is not correct,
// create a new splitter, put the 2 terms into the splitter,
// and put the splitter the right postion.
int index = 0;
if (splitter) {
index = splitter->indexOf(term);
} else {
index = m_layout->indexOf(term);
}

// and replace the old term with the splitter.
QSplitter *newSplitter = createSubSplit(term, orientation);

if (splitter) {
Expand Down

0 comments on commit 7dc5ab4

Please sign in to comment.