@@ -49,6 +49,11 @@ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int
4949 try {
5050 IDocument document = viewer .getDocument ();
5151 IRegion lineInfo = document .getLineInformationOfOffset (offset );
52+ if (isCommentLine (document , lineInfo ) || isInstructionLine (document , lineInfo )
53+ || isContinuationLine (document , lineInfo , false )) {
54+ // do not even try proposals
55+ return new ICompletionProposal [0 ];
56+ }
5257 if (lineInfo .getOffset () != offset ) {
5358 String pre = document .get (0 , offset );
5459 Matcher matcher = PREFIX_PATTERN .matcher (pre );
@@ -78,6 +83,44 @@ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int
7883 }
7984 }
8085
86+ private boolean isContinuationLine (IDocument document , IRegion lineInfo , boolean onlyCurrent ) {
87+ int o = lineInfo .getOffset ();
88+ int l = lineInfo .getLength ();
89+ try {
90+ String line = document .get (o , l );
91+ if (line .trim ().endsWith ("\\ " )) {
92+ // the line itself is a continuation line
93+ return true ;
94+ } else if (onlyCurrent ) {
95+ return false ;
96+ }
97+ return isContinuationLine (document , document .getLineInformationOfOffset (o - 1 ), true );
98+ } catch (BadLocationException e ) {
99+ return false ;
100+ }
101+ }
102+
103+ private boolean isInstructionLine (IDocument document , IRegion lineInfo ) {
104+ int o = lineInfo .getOffset ();
105+ int l = lineInfo .getLength ();
106+ try {
107+ String line = document .get (o , l );
108+ return line .indexOf (':' ) > -1 || line .indexOf ('=' ) > -1 ;
109+ } catch (BadLocationException e ) {
110+ return false ;
111+ }
112+ }
113+
114+ protected boolean isCommentLine (IDocument document , IRegion lineInfo ) {
115+ int o = lineInfo .getOffset ();
116+ int l = lineInfo .getLength ();
117+ try {
118+ return document .get (o , l ).startsWith ("#" );
119+ } catch (BadLocationException e ) {
120+ return false ;
121+ }
122+ }
123+
81124 private static ICompletionProposal [] proposals (String prefix , int offset ) {
82125 ArrayList <ICompletionProposal > results = new ArrayList <>(Syntax .HELP .size ());
83126 for (Syntax s : Syntax .HELP .values ()) {
0 commit comments