mirror of
				https://github.com/go-delve/delve.git
				synced 2025-10-31 18:57:18 +08:00 
			
		
		
		
	terminal: show message if there are no vars/locals/args
When the vars, locals, or args commands return no results, nothing is printed out to the terminal. This commit makes these commands print a message like `(no locals)` when there is nothing to show. This feedback is more descriptive of what is being returned than an empty string.
This commit is contained in:
		 Wesley Merkel
					Wesley Merkel
				
			
				
					committed by
					
						 Derek Parker
						Derek Parker
					
				
			
			
				
	
			
			
			 Derek Parker
						Derek Parker
					
				
			
						parent
						
							ae7abe1a9d
						
					
				
				
					commit
					e60942a39d
				
			| @ -682,7 +682,7 @@ func args(t *Term, ctx callContext, filter string) ([]string, error) { | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return filterVariables(vars, filter), nil | ||||
| 	return describeNoVars("args", filterVariables(vars, filter)), nil | ||||
| } | ||||
|  | ||||
| func locals(t *Term, ctx callContext, filter string) ([]string, error) { | ||||
| @ -690,7 +690,7 @@ func locals(t *Term, ctx callContext, filter string) ([]string, error) { | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return filterVariables(locals, filter), nil | ||||
| 	return describeNoVars("locals", filterVariables(locals, filter)), nil | ||||
| } | ||||
|  | ||||
| func vars(t *Term, ctx callContext, filter string) ([]string, error) { | ||||
| @ -698,7 +698,7 @@ func vars(t *Term, ctx callContext, filter string) ([]string, error) { | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return filterVariables(vars, filter), nil | ||||
| 	return describeNoVars("vars", filterVariables(vars, filter)), nil | ||||
| } | ||||
|  | ||||
| func regs(t *Term, ctx callContext, args string) error { | ||||
| @ -1153,3 +1153,10 @@ func formatBreakpointLocation(bp *api.Breakpoint) string { | ||||
| 	} | ||||
| 	return fmt.Sprintf("%#v for %s:%d", bp.Addr, p, bp.Line) | ||||
| } | ||||
|  | ||||
| func describeNoVars(varType string, data []string) []string { | ||||
| 	if len(data) == 0 { | ||||
| 		return []string{fmt.Sprintf("(no %s)", varType)} | ||||
| 	} | ||||
| 	return data | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user