[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/kdevelop/3.4/parts/astyle
From: Jens Dagerbo <jens.dagerbo () swipnet ! se>
Date: 2006-03-25 17:59:00
Message-ID: 1143309540.912828.6247.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 522475 by dagerbo:
Don't remove newline if it should be there. Fixes bug #111413
M +16 -15 astyle_part.cpp
--- branches/kdevelop/3.4/parts/astyle/astyle_part.cpp #522474:522475
@@ -63,13 +63,13 @@
return;
bool has_selection = false;
-
+
KTextEditor::SelectionInterface *sel_iface
= dynamic_cast<KTextEditor::SelectionInterface*>(partController()->activePart());
if (sel_iface && sel_iface->hasSelection())
has_selection = true;
- //if there is a selection, we only format it.
+ //if there is a selection, we only format it.
ASStringIterator is(has_selection ? sel_iface->selection() : iface->text());
KDevFormatter formatter;
@@ -83,21 +83,22 @@
uint col = 0;
uint line = 0;
-
+
if(has_selection) //there was a selection, so only change the part of the text related to it
{
- //remove the final newline character
- output.setLength(output.length()-1);
-
+ //remove the final newline character, unless it should be there
+ if ( !sel_iface->selection().endsWith( "\n" ) )
+ output.setLength(output.length()-1);
+
sel_iface->removeSelectedText();
- cursorPos( partController()->activePart(), &col, &line );
+ cursorPos( partController()->activePart(), &col, &line );
iface->insertText( col, line, output);
-
+
return;
}
- cursorPos( partController()->activePart(), &col, &line );
-
+ cursorPos( partController()->activePart(), &col, &line );
+
iface->setText( output );
setCursorPos( partController()->activePart(), col, line );
@@ -149,17 +150,17 @@
{
ASStringIterator is(text);
KDevFormatter * formatter = ( widget ? new KDevFormatter( widget ) : new KDevFormatter );
-
+
formatter->init(&is);
-
+
QString output;
QTextStream os(&output, IO_WriteOnly);
-
+
while ( formatter->hasMoreLines() )
os << QString::fromUtf8( formatter->nextLine().c_str() ) << endl;
-
+
delete formatter;
-
+
return output;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic