diff --git a/CodeLite/commentconfigdata.h b/CodeLite/commentconfigdata.h index a1c1b6f580..77aae15040 100644 --- a/CodeLite/commentconfigdata.h +++ b/CodeLite/commentconfigdata.h @@ -46,14 +46,14 @@ class WXDLLIMPEXP_CL CommentConfigData : public SerializedObject virtual void Serialize(Archive& arch); // Setters - void SetAddStarOnCComment(const bool& addStarOnCComment) { this->m_addStarOnCComment = addStarOnCComment; } + void SetAddStarOnCComment(bool addStarOnCComment) { this->m_addStarOnCComment = addStarOnCComment; } void SetClassPattern(const wxString& classPattern) { this->m_classPattern = classPattern; } - void SetContinueCppComment(const bool& continueCppComment) { this->m_continueCppComment = continueCppComment; } + void SetContinueCppComment(bool continueCppComment) { this->m_continueCppComment = continueCppComment; } void SetFunctionPattern(const wxString& functionPattern) { this->m_functionPattern = functionPattern; } const bool& GetAddStarOnCComment() const { return m_addStarOnCComment; } const wxString& GetClassPattern() const { return m_classPattern; } - const bool& GetContinueCppComment() const { return m_continueCppComment; } + bool GetContinueCppComment() const { return m_continueCppComment; } const wxString& GetFunctionPattern() const { return m_functionPattern; } void SetUseQtStyle(bool useQtStyle) { this->m_useQtStyle = useQtStyle; } bool IsUseQtStyle() const { return m_useQtStyle; } diff --git a/LiteEditor/ContextRust.cpp b/LiteEditor/ContextRust.cpp index 30841be0b7..11378c4eaf 100644 --- a/LiteEditor/ContextRust.cpp +++ b/LiteEditor/ContextRust.cpp @@ -22,15 +22,18 @@ // ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#include "wx/versioninfo.h" +#include "commentconfigdata.h" -// rust support was added in wx3.1 +#include + +// Rust support was added in wx3.1 #if wxCHECK_VERSION(3, 1, 0) #include "ContextRust.hpp" #include "cl_editor.h" #include "cl_editor_tip_window.h" #include "editor_config.h" +#include "file_logger.h" #include #include @@ -84,7 +87,44 @@ void ContextRust::ApplySettings() DoApplySettings(lexPtr); } -void ContextRust::AutoIndent(const wxChar& nChar) { ContextGeneric::AutoIndent(nChar); } +void ContextRust::AutoIndent(const wxChar& nChar) +{ + clEditor& rCtrl = GetCtrl(); + CommentConfigData data; + EditorConfigST::Get()->ReadObject("CommentConfigData", &data); + + int curpos = rCtrl.GetCurrentPos(); + int prev_pos = rCtrl.PositionBeforePos(curpos); + + if (rCtrl.GetDisableSmartIndent()) { + return; + } + + if (nChar == '\n' && data.GetContinueCppComment()) { + // Single line comment? + wxString prev_line = rCtrl.GetLine(rCtrl.LineFromPosition(prev_pos)); + prev_line.Trim().Trim(false); + wxString to_insert; + if (prev_line.StartsWith("///")) { + to_insert = "/// "; + } else if (prev_line.StartsWith("//")) { + to_insert = "// "; + } + + if (!to_insert.empty()) { + int line = rCtrl.LineFromPosition(curpos); + rCtrl.SetLineIndentation(line, rCtrl.GetLineIndentation(line - 1)); + int insertPos = rCtrl.GetLineIndentPosition(line); + rCtrl.InsertText(insertPos, to_insert); + rCtrl.SetCaretAt(insertPos + to_insert.Length()); + rCtrl.ChooseCaretX(); // set new column as "current" column + return; + } + } + + // Default behavior + ContextGeneric::AutoIndent(nChar); +} wxString ContextRust::CallTipContent() { return wxEmptyString; } diff --git a/Plugin/clFileSystemWorkspace.cpp b/Plugin/clFileSystemWorkspace.cpp index a1fb451c90..01e6478a72 100644 --- a/Plugin/clFileSystemWorkspace.cpp +++ b/Plugin/clFileSystemWorkspace.cpp @@ -213,7 +213,6 @@ void clFileSystemWorkspace::CacheFiles(bool force) } } - clSYSTEM() << "Scan called with:" << excludeFolders << endl; fs.Scan(rootFolder, files, GetFilesMask(), "", excludeFolders); clFileSystemEvent event(wxEVT_FS_SCAN_COMPLETED); wxArrayString arrfiles;