Git commit 3e51177c519aa2b1c1d2f246db05f3d304a608b8 by Sven Brauch. Committed on 31/08/2014 at 21:16. Pushed by brauch into branch '0.6'. Finally fix the tab problem by using the replace-tabs key of the ConfigIface M +0 -8 common/CMakeLists.txt M +7 -35 common/document.cpp http://commits.kde.org/kte-collaborative/3e51177c519aa2b1c1d2f246db05f3d304= a608b8 diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 0efceac..3d81989 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -2,14 +2,6 @@ # The common directory (and library) contais functionality which is common= to both the KTE plugin and the kioslave. # Since both need the whole connection and browser stuff, this is a quite = large part of the code base. = -# Check if KTE is new enough to have the BufferInterface -try_compile( HAVE_BUFFERIFACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_= SOURCE_DIR}/testbufferinterface.cpp - CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=3D${KDE4_INCLUDES}" - LINK_LIBRARIES ${KDE4_KTEXTEDITOR_LIBS} ) -if(HAVE_BUFFERIFACE) - add_definitions("-DKTEXTEDITOR_HAS_BUFFER_IFACE") -endif(HAVE_BUFFERIFACE) - include_directories( ${KDE4_INCLUDES} ${LIBQINFINITY_INCLUDES} diff --git a/common/document.cpp b/common/document.cpp index 8484b99..5f2881a 100644 --- a/common/document.cpp +++ b/common/document.cpp @@ -52,9 +52,7 @@ #include #include = -#ifdef KTEXTEDITOR_HAS_BUFFER_IFACE -#include -#endif +#include = namespace Kobby { @@ -65,6 +63,8 @@ Document::Document( KTextEditor::Document* kDocument ) , m_dirty( false ) { m_kDocument->setParent( 0 ); + KTextEditor::ConfigInterface* iface =3D qobject_cast(m_kDocument); + iface->setConfigValue("replace-tabs", false); connect( m_kDocument, SIGNAL(textChanged( KTextEditor::Document* )), this, SLOT(textChanged( KTextEditor::Document* )) ); connect( m_kDocument, SIGNAL(documentSavedOrUploaded( KTextEditor::Doc= ument*, @@ -215,26 +215,10 @@ void KDocumentTextBuffer::onInsertText( unsigned int = offset, KTextEditor::Cursor startCursor =3D offsetToCursor_kte( offset ); QString str =3D codec()->toUnicode( chunk.text() ); ReadWriteTransaction transaction(kDocument()); -#ifdef KTEXTEDITOR_HAS_BUFFER_IFACE - // The compile-time check just verifies that the interface is pres= ent. - // This does not guarantee that it is supported by the KTE impleme= ntation used here. - if ( KTextEditor::BufferInterface* iface =3D qobject_cast(kDocument()) ) { - iface->insertTextSilent(startCursor, str); - } -#else - if ( false ) { } -#endif - else { - kDebug() << "Text editor does not support the Buffer interface= . Using workaround for tabs."; -#ifdef ENABLE_TAB_HACK - // If we don't have the buffer iface and the tab hack is enabl= ed, replace - // all tabs by 1 space. That won't break stuff, since it has t= he same length - str =3D str.replace("\t", " "); -#endif - kDocument()->blockSignals(true); - kDocument()->insertText( startCursor, str ); - kDocument()->blockSignals(false); - } + kDocument()->blockSignals(true); + kDocument()->insertText( startCursor, str ); + kDocument()->blockSignals(false); + Q_ASSERT(!qobject_cast(kDocument())= ->configValue("replace-tabs").toBool()); emit remoteChangedText(KTextEditor::Range(startCursor, offsetToCur= sor_kte(offset+chunk.length())), user, false); checkConsistency(); } @@ -284,18 +268,6 @@ void KDocumentTextBuffer::onEraseText( unsigned int of= fset, void KDocumentTextBuffer::checkConsistency() { QString bufferContents =3D codec()->toUnicode( slice(0, length())->tex= t() ); -#ifndef KTEXTEDITOR_HAS_BUFFER_IFACE - if ( false ) { } -#else - if ( qobject_cast(kDocument()) ) { } -#endif -#ifdef ENABLE_TAB_HACK - else { - // In this case, it's allowed that the buffer and the document dif= fer in tabs being - // replaced by spaces. - bufferContents =3D bufferContents.replace("\t", " "); - } -#endif QString documentContents =3D kDocument()->text(); if ( bufferContents !=3D documentContents ) { KUrl url =3D kDocument()->url();