eclipse-bash-editor icon indicating copy to clipboard operation
eclipse-bash-editor copied to clipboard

local variables in outline: fix bug on display under function; introduce hiding in list above functions

Open sebalis opened this issue 3 years ago • 2 comments

Hi, there seems to be an inconsistency in the way local variables are handled in the outline window, here is an example:

#!/bin/bash

f_a() {
  local v_a
  v_a="_"
  echo $v_a
}

f_b() {
  local v_b=""
  v_b="."
}

v_global=1

v_exported=2
export v_exported

If this file is opened in Eclipse with Bash Editor, the Outline window shows all variables first, and function_b has an expandable sublist containing var_b. But function_a does not have a corresponding sublist. That seems like a bug to me, unless I’ve overlooked something?

I also have a request: It should be possible to make the list of above the list of functions show only global variables – if not by default, then through an option. Maybe different icons could also be used to distinguish local from global variables. And I wonder if exported variables should be treated differently again, although I realise that variables can have a “double life” starting out as local or global variables and then being exported later.

Thank you for your work.

sebalis avatar Jul 22 '21 20:07 sebalis

(I also realise that a local variable can start out as non-local, but that is not the reason for Bash Editor to treat it differently. If I change function_b to

f_b() {
  v_b="-"
  local v_b=""
  v_b="."
}

then v_b changes from being global to local; callers to f_b will see v_b set to the first value ("-") after f_b is run. But Bash Editor still shows v_b in the sublist of f_b as if it were a “true” local.)

sebalis avatar Jul 22 '21 20:07 sebalis

Thanx for reporting the bug.

When I try your example I got following output inside IDE: image

Yes. The local variables are not handled correctly here. Must be fixed.

de-jcup avatar Dec 30 '21 08:12 de-jcup