mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-26 08:08:28 +03:00
Fixes an issue when reloading documents (file system change) that disabled the linter by mistake.
This commit is contained in:
@@ -867,6 +867,8 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client {
|
||||
|
||||
virtual void onDocumentLoaded( TextDocument* doc );
|
||||
|
||||
virtual void onDocumentReloaded( TextDocument* doc );
|
||||
|
||||
virtual void onDocumentLoaded();
|
||||
|
||||
virtual void onDocumentChanged();
|
||||
|
||||
@@ -1230,4 +1230,5 @@ std::string Sys::getProcessFilePath() {
|
||||
return std::string( exename );
|
||||
#endif
|
||||
}
|
||||
|
||||
}} // namespace EE::System
|
||||
|
||||
@@ -443,7 +443,7 @@ TextDocument::LoadStatus UICodeEditor::loadFromFile( const std::string& path ) {
|
||||
invalidateEditor();
|
||||
updateLongestLineWidth();
|
||||
invalidateDraw();
|
||||
onDocumentLoaded( mDoc.get() );
|
||||
onDocumentLoaded();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -577,6 +577,11 @@ void UICodeEditor::onFontStyleChanged() {
|
||||
|
||||
void UICodeEditor::onDocumentLoaded( TextDocument* ) {}
|
||||
|
||||
void UICodeEditor::onDocumentReloaded( TextDocument* ) {
|
||||
onDocumentClosed( mDoc.get() );
|
||||
onDocumentLoaded();
|
||||
}
|
||||
|
||||
void UICodeEditor::onDocumentLoaded() {
|
||||
DocEvent event( this, mDoc.get(), Event::OnDocumentLoaded );
|
||||
sendEvent( &event );
|
||||
|
||||
@@ -2423,6 +2423,8 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) {
|
||||
} );
|
||||
|
||||
auto docChanged = [this]( const Event* event ) {
|
||||
if ( !Engine::isRunninMainThread() )
|
||||
return;
|
||||
const DocEvent* synEvent = static_cast<const DocEvent*>( event );
|
||||
UICodeEditor* editor = event->getNode()->asType<UICodeEditor>();
|
||||
UIIcon* icon = mUISceneNode->findIcon(
|
||||
|
||||
@@ -104,6 +104,8 @@ void AutoCompletePlugin::onRegister( UICodeEditor* editor ) {
|
||||
listeners.push_back(
|
||||
editor->addEventListener( Event::OnDocumentLoaded, [&, editor]( const Event* ) {
|
||||
mDirty = true;
|
||||
mDocs.insert( editor->getDocumentRef().get() );
|
||||
mEditorDocs[editor] = editor->getDocumentRef().get();
|
||||
tryRequestCapabilities( editor );
|
||||
} ) );
|
||||
|
||||
|
||||
@@ -590,9 +590,11 @@ void LinterPlugin::onRegister( UICodeEditor* editor ) {
|
||||
std::vector<Uint32> listeners;
|
||||
|
||||
listeners.push_back(
|
||||
editor->addEventListener( Event::OnDocumentLoaded, [this]( const Event* event ) {
|
||||
editor->addEventListener( Event::OnDocumentLoaded, [this, editor]( const Event* event ) {
|
||||
Lock l( mDocMutex );
|
||||
const DocEvent* docEvent = static_cast<const DocEvent*>( event );
|
||||
mDocs.insert( docEvent->getDoc() );
|
||||
mEditorDocs[editor] = docEvent->getDoc();
|
||||
setDocDirty( docEvent->getDoc() );
|
||||
} ) );
|
||||
|
||||
@@ -615,6 +617,7 @@ void LinterPlugin::onRegister( UICodeEditor* editor ) {
|
||||
mDocs.erase( oldDoc );
|
||||
mDirtyDoc.erase( oldDoc );
|
||||
mEditorDocs[editor] = newDoc;
|
||||
mDocs.insert( newDoc );
|
||||
Lock matchesLock( mMatchesMutex );
|
||||
mMatches.erase( oldDoc );
|
||||
} ) );
|
||||
|
||||
@@ -572,9 +572,11 @@ void PluginBase::onRegister( UICodeEditor* editor ) {
|
||||
std::vector<Uint32> listeners;
|
||||
|
||||
listeners.push_back(
|
||||
editor->addEventListener( Event::OnDocumentLoaded, [this]( const Event* event ) {
|
||||
editor->addEventListener( Event::OnDocumentLoaded, [this, editor]( const Event* event ) {
|
||||
Lock l( mMutex );
|
||||
const DocEvent* docEvent = static_cast<const DocEvent*>( event );
|
||||
mDocs.insert( docEvent->getDoc() );
|
||||
mEditorDocs[editor] = docEvent->getDoc();
|
||||
onDocumentLoaded( docEvent->getDoc() );
|
||||
} ) );
|
||||
|
||||
@@ -596,6 +598,7 @@ void PluginBase::onRegister( UICodeEditor* editor ) {
|
||||
TextDocument* newDoc = editor->getDocumentRef().get();
|
||||
Lock l( mMutex );
|
||||
mDocs.erase( oldDoc );
|
||||
mDocs.insert( newDoc );
|
||||
mEditorDocs[editor] = newDoc;
|
||||
onDocumentChanged( editor, oldDoc );
|
||||
} ) );
|
||||
|
||||
Reference in New Issue
Block a user