@@ -315,7 +315,7 @@ static void InvokeShortcutHandler(Action action)
315315 Cursor . Current = Cursors . Default ;
316316 }
317317
318- static void HandleErrors ( Action action )
318+ static void HandleErrors ( Action action , Action finalAction = null )
319319 {
320320 try
321321 {
@@ -330,6 +330,10 @@ static void HandleErrors(Action action)
330330#else
331331 catch { }
332332#endif
333+ finally
334+ {
335+ finalAction ? . Invoke ( ) ;
336+ }
333337 }
334338
335339 static SnippetContext currentSnippetContext = null ;
@@ -552,8 +556,14 @@ static public void OnBeforeDocumentSaved()
552556 private const int MARK_BREAKPOINT = 7 ;
553557 private const int MARK_BREAKPOINT_MASK = 1 << 7 ;
554558
559+ static bool formattingInProgress = false ;
555560 static void FormatDocument ( )
556561 {
562+ if ( formattingInProgress )
563+ return ; //aborting non critical operation
564+
565+ formattingInProgress = true ;
566+
557567 HandleErrors ( ( ) =>
558568 {
559569 if ( Npp . Editor . IsCurrentDocScriptFile ( ) )
@@ -582,7 +592,8 @@ static void FormatDocument()
582592 doc . PlaceMarker ( MARK_BREAKPOINT , line_after ) ;
583593 }
584594 }
585- } ) ;
595+ } ,
596+ ( ) => formattingInProgress = false ) ;
586597 }
587598
588599 static void GoToDefinition ( )
@@ -941,10 +952,10 @@ static void ShowSuggestionList(bool snippetsOnly, bool memberInfoWasShowing = fa
941952
942953 var document = Npp . GetCurrentDocument ( ) ;
943954 Action < ICompletionData > OnAccepted = data => OnAutocompletionAccepted ( data , snippetsOnly ) ;
944-
955+
945956 // no need to pass initial SuggestionHint as it may swallow (auto accept) the whole autocompletion window
946957 // in case of the hint to be the full match of one of the items. Just do it for a better UX
947-
958+
948959 autocompleteForm = new AutocompleteForm ( OnAccepted , items , null ) ;
949960 autocompleteForm . Left = point . X ;
950961 autocompleteForm . Top = point . Y + document . TextHeight ( document . GetCurrentLineNumber ( ) ) ;
@@ -1155,7 +1166,7 @@ static void Reparse()
11551166 currentFile = null ;
11561167 EnsureCurrentFileParsedAsynch ( ) ;
11571168 }
1158-
1169+
11591170 static string [ ] mustBeAssignedWithLitterals = "var,string,String,bool,byte,sbyte,char,decimal,double,float,int,uint,long,ulong,short,ushort,Byte,SByte,Char,Decimal,Double,Single,Int32,UInt32,Int64,UInt64,Int16,UInt16,IntPtr" . Split ( ',' ) ;
11601171
11611172 static public void OnCharTyped ( char c )
0 commit comments