mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	
							parent
							
								
									f734590f8e
								
							
						
					
					
						commit
						4e40b7ddb0
					
				
					 2 changed files with 17 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -315,12 +315,19 @@ module IRB
 | 
			
		|||
        end
 | 
			
		||||
 | 
			
		||||
      else
 | 
			
		||||
        candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
 | 
			
		||||
        candidates |= ReservedWords
 | 
			
		||||
 | 
			
		||||
        if doc_namespace
 | 
			
		||||
          candidates.find{ |i| i == input }
 | 
			
		||||
          vars = eval("local_variables | instance_variables", bind).collect{|m| m.to_s}
 | 
			
		||||
          perfect_match_var = vars.find{|m| m.to_s == input}
 | 
			
		||||
          if perfect_match_var
 | 
			
		||||
            eval("#{perfect_match_var}.class.name", bind)
 | 
			
		||||
          else
 | 
			
		||||
            candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
 | 
			
		||||
            candidates |= ReservedWords
 | 
			
		||||
            candidates.find{ |i| i == input }
 | 
			
		||||
          end
 | 
			
		||||
        else
 | 
			
		||||
          candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
 | 
			
		||||
          candidates |= ReservedWords
 | 
			
		||||
          candidates.grep(/^#{Regexp.quote(input)}/)
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -83,5 +83,11 @@ module TestIRB
 | 
			
		|||
        assert_include candidates, word
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def test_complete_variable
 | 
			
		||||
      str_example = ''
 | 
			
		||||
      assert_include(IRB::InputCompletor.retrieve_completion_data("str_examp", bind: binding), "str_example")
 | 
			
		||||
      assert_equal(IRB::InputCompletor.retrieve_completion_data("str_example", bind: binding, doc_namespace: true), "String")
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue