Skip to content

Commit

Permalink
Vulkan: Ensure autocomplete recognizes leading tabs in the shader syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
JKSunny committed Oct 14, 2024
1 parent 7a69fe6 commit 8e6c6f2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
22 changes: 19 additions & 3 deletions codemp/rd-vulkan/utils/ImGuiColorTextEdit/TextEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ void TextEditor::AutoComplete( void )
if ( mTextChangedDelayed )
{
uint32_t i;
std::string selectedText = GetCurrentLineText();
std::string selectedText = GetCurrentLineText( true );

AutoCompleteListClear();

Expand Down Expand Up @@ -2777,11 +2777,27 @@ std::string TextEditor::GetSelectedText() const
return GetText(mState.mSelectionStart, mState.mSelectionEnd);
}

std::string TextEditor::GetCurrentLineText()const
std::string TextEditor::GetCurrentLineText( bool ignoreLeadingSpace ) const
{
auto lineLength = GetLineMaxColumn(mState.mCursorPosition.mLine);

int start = 0;

if ( ignoreLeadingSpace )
{
auto& line = mLines[mState.mCursorPosition.mLine];

while ( start < line.size() && isspace( line[start].mChar ) )
start++;

if ( start >= line.size() )
return "";

start = GetCharacterColumn( mState.mCursorPosition.mLine, start );
}

return GetText(
Coordinates(mState.mCursorPosition.mLine, 0),
Coordinates(mState.mCursorPosition.mLine, start ),
Coordinates(mState.mCursorPosition.mLine, lineLength));
}

Expand Down
2 changes: 1 addition & 1 deletion codemp/rd-vulkan/utils/ImGuiColorTextEdit/TextEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class TextEditor
std::vector<std::string> GetTextLines() const;

std::string GetSelectedText() const;
std::string GetCurrentLineText()const;
std::string GetCurrentLineText( bool ignoreLeadingSpace = false ) const;

int GetTotalLines() const { return (int)mLines.size(); }
bool IsOverwrite() const { return mOverwrite; }
Expand Down

0 comments on commit 8e6c6f2

Please sign in to comment.