Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Variable name auto-fill/suggestions not appearing for in-line locals

    Lately, when coding in Stata, the auto-fill suggestions for variables is not popping up when calling a local, when not at the beginning of a line. To be clear, the auto-fill is working (regardless of position) for regular variables and for globals. It also works for locals, when no text precedes the called local in the line.

    To clarify what I mean, take the following code:

    Code:
    gen test_var = 10
    global test_global = 15
    local test_local = 20
    If I type the expression

    Code:
    local test_calculation = ${test_global} + `test_local'
    then Stata will automatically suggest names for the test_global variable and not do so for the test_local variable. However, if I simply type this

    Code:
    `test_local'
    then Stata will suggest names for the local.

    I haven't always had this issue; it started a few months ago and has been persistent. I recently updated to StataNow 18, but no dice. I've tried changing Stata's auto-fill settings, but they all seem to be correct. I've attached my Stata auto-completion settings; everything is enabled except for "Ignore text in comments."

    Click image for larger version

Name:	bJ8ucwUr.png
Views:	1
Size:	72.9 KB
ID:	1772300


  • #2
    I think it doesn't really work for globals either. The reason it appears to is because you have wrapped test_global inside curly braces. But if you try the same line without the curly braces:
    Code:
    local test_calculation = $test_global + `test_local'
    neither the global nor the local will offer autofill. However, if you type $test_global at the beginning of the line, then, just as with `test_local', you will get auto-fill.

    Anyway, you are write that autofill seems to fail to recognize local macros unless they are at the beginning of the line. The same is actually true for global macros, except that a global macro can be "rescued" with curly braces, a trick not available with local macros. (It is not available with local macros in the sense that `{test_local}' is syntactically acceptable, and it does trigger autocompletion, but it is not expanded as if it were local macro test_local: it expands to an empty string.)

    This seems to be a bug in the do-file editor. I recommend you contact Technical Support about it.

    Comment


    • #3
      FYI: autocompletion of local an global macros requires that the local and global macros be in memory which means your do file probably has to be executed at least once if the macros weren't already defined elsewhere. Autocompleting global and local macros within a do file and not just from memory is on our todo list.
      -Chinh Nguyen

      Comment

      Working...
      X