Author Topic: Preprocessor Completion  (Read 13386 times)

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Preprocessor Completion
« on: November 29, 2012, 12:11:54 am »
Attached is a patch that modifies CC's behavior for preprocessor completion.
  • Completing headers and PP directives have icons
  • PP tokens are available after an #ifdef (and such)
  • Typing a "#" in, for example, Python (any non C-family language), will not trigger PP directive listing
  • Comments on the same line as a completing PP directive are not deleted
  • Completing headers and PP directives activates/works more reliably
  • Undo actions are not unnecessarily generated when CC makes no change
  • Auto-completion box refines its listing of header files every directory
  • Keyboard shortcuts Ctrl-Enter and Shift-Enter do not conflict with auto-completion

If anyone has time to test, I would appreciate some feedback on these modifications.  (My local copy seems to have been accumulating some changes, so I thought I would share :).)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Preprocessor Completion
« Reply #1 on: December 02, 2012, 04:58:54 am »
Question on the documents:
Quote
Undo actions are not unnecessarily generated when CC makes no change
What does this means?
Undo actions are necessarily generated when CC makes no change?

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Preprocessor Completion
« Reply #2 on: December 03, 2012, 04:06:20 am »
Undo actions are necessarily generated when CC makes no change?
Code
@@ -1435,7 +1518,8 @@
                     itemText << _T('>');
             }
 
-            control->ReplaceTarget(itemText);
+            if (control->GetTextRange(startPos, curPos) != itemText)
+                control->ReplaceTarget(itemText);
             control->GotoPos(startPos + itemText.Length());
 
             if (needReparse)
The current system can create two undo actions when completing a PP command (1: delete rest of line, 2: insert new token), this is now condensed to one step.
The current system also will create an undo action if the resulting text is no different than what it first was.  For example, open a source file, click on a token, press Ctrl-Space (call CC), and select the same token from the list.  The current line looks no different, but an undo action is generated, and the line/file is marked as modified.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Preprocessor Completion
« Reply #3 on: December 06, 2012, 02:32:29 am »
As it seems not much discussion has been generated, submitted patch 3391 (contains a few extra in-line comments, and prevents Undo Ctrl-Z from conflicting with auto-completion, but no other changes).