mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-04 20:46:29 +03:00
Fix reset syntax on saved or moved doc.
This commit is contained in:
@@ -435,6 +435,8 @@ class EE_API TextDocument {
|
||||
|
||||
void setNonWordChars( const String& nonWordChars );
|
||||
|
||||
const SyntaxDefinition& guessSyntax() const;
|
||||
|
||||
void resetSyntax();
|
||||
|
||||
bool getAutoDetectIndentType() const;
|
||||
|
||||
@@ -375,6 +375,11 @@ bool TextDocument::hasSyntaxDefinition() const {
|
||||
return !mSyntaxDefinition.getPatterns().empty();
|
||||
}
|
||||
|
||||
const SyntaxDefinition& TextDocument::guessSyntax() const {
|
||||
String header( getText( { { 0, 0 }, positionOffset( { 0, 0 }, 128 ) } ) );
|
||||
return SyntaxDefinitionManager::instance()->find( mFilePath, header, mHAsCpp );
|
||||
}
|
||||
|
||||
void TextDocument::resetSyntax() {
|
||||
String header( getText( { { 0, 0 }, positionOffset( { 0, 0 }, 128 ) } ) );
|
||||
std::string oldDef = mSyntaxDefinition.getLSPName();
|
||||
|
||||
@@ -2592,8 +2592,7 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) {
|
||||
refreshFolderView();
|
||||
}
|
||||
if ( !editor->getDocument().hasSyntaxDefinition() ) {
|
||||
editor->getDocument().resetSyntax();
|
||||
editor->setSyntaxDefinition( editor->getDocument().getSyntaxDefinition() );
|
||||
editor->setSyntaxDefinition( editor->getDocument().guessSyntax() );
|
||||
}
|
||||
} );
|
||||
|
||||
@@ -2642,8 +2641,7 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) {
|
||||
UICodeEditor* editor = event->getNode()->asType<UICodeEditor>();
|
||||
editor->runOnMainThread( [this, editor] {
|
||||
updateEditorTabTitle( editor );
|
||||
editor->getDocument().resetSyntax();
|
||||
editor->setSyntaxDefinition( editor->getDocument().getSyntaxDefinition() );
|
||||
editor->setSyntaxDefinition( editor->getDocument().guessSyntax() );
|
||||
} );
|
||||
} );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user