Skip to content

Commit

Permalink
Fixed: Rust: the configuration option "Hitting ENTER in a C++ comment…
Browse files Browse the repository at this point in the history
… adds '//'" does not work

Removed un-needed log line entry
  • Loading branch information
eranif committed May 15, 2024
1 parent 7f7adb2 commit f000c35
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
6 changes: 3 additions & 3 deletions CodeLite/commentconfigdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
46 changes: 43 additions & 3 deletions LiteEditor/ContextRust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#include "wx/versioninfo.h"
#include "commentconfigdata.h"

// rust support was added in wx3.1
#include <wx/versioninfo.h>

// 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 <unordered_set>
#include <wx/xrc/xmlres.h>
Expand Down Expand Up @@ -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; }

Expand Down
1 change: 0 additions & 1 deletion Plugin/clFileSystemWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f000c35

Please sign in to comment.