bool use_tabs = EditorSettings::get(EditorSettings::UseTabs); // Stores final result whether document uses tabs for indentation (start with default)
int indentation_width = EditorSettings::get(EditorSettings::TabWidth); // Stores final result what indentation width the document uses (start with default)
-
+
if ( !Juff::Document::isNoname(fileName) && EditorSettings::get(EditorSettings::AutoDetectIndentation) ) {
QFile file(fileName);
if ( file.open(QIODevice::ReadOnly) ) {
int tab_block_count = 0; // Counter of how many text blocks start with tabs
int space_block_count = 0; // Counter of how many text blocks start with spaces
// Guess indentation style based on the collected statistics
if (tab_block_count > 0 || space_block_count > 0) { // If we don't have any statistics to work with, stick with defaults
if ( (tab_block_count * 2) > space_block_count ) { // Heuristic: even smaller numbers of leading tabs typically still indicate that tabs are the indentation character