Skip to content

Commit

Permalink
Merge pull request #102 from DikBSD/fixCodeAtom
Browse files Browse the repository at this point in the history
Сделано атомарная обработка для форматирования в Code
  • Loading branch information
xintrea committed Dec 27, 2018
2 parents a63f2f2 + 93fd47f commit 771a336
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/src/libraries/wyedit/formatters/TypefaceFormatter.cpp
Expand Up @@ -173,6 +173,8 @@ void TypefaceFormatter::onCodeClicked(void)
if(!textArea->textCursor().hasSelection())
return;

textArea->textCursor().beginEditBlock();

// Обработка мягкого переноса в выделенном тексте
// Учитываются мягкие переносы до выделенного текста (1-й символ до выделения) и в выделенных абзацах
workingSoftCarryInSelection();
Expand Down Expand Up @@ -209,8 +211,6 @@ void TypefaceFormatter::onCodeClicked(void)
enableIndent=true; // Выбран четко блок (блоки) текста, нужно делать отступ


textArea->textCursor().beginEditBlock();

// Вначале происходит преобразование фрагмента в чистый текст (onClearClicked() не подходит, так как съедается табуляция)
onTextOnlyClicked();

Expand Down Expand Up @@ -1178,6 +1178,8 @@ void TypefaceFormatter::workingSoftCarryInSelection()
if(!textArea->textCursor().hasSelection())
return;

int scrollBarPosition=editor->getScrollBarPosition();

// Запоминаем первоначальное выделение текста
int selectionStart = textArea->textCursor().selectionStart();
int selectionEnd = textArea->textCursor().selectionEnd();
Expand Down Expand Up @@ -1233,5 +1235,7 @@ void TypefaceFormatter::workingSoftCarryInSelection()
textCursor.setPosition(selectionStart, QTextCursor::MoveAnchor);
textCursor.setPosition(selectionEnd, QTextCursor::KeepAnchor);
textArea->setTextCursor(textCursor);

editor->setScrollBarPosition(scrollBarPosition);
}

0 comments on commit 771a336

Please sign in to comment.