changeset 8:5cd58b3fd93d

Clean-up project name before setting it, and do proper error reporting.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 26 Jan 2021 12:00:31 -0800
parents 59d75d8c254f
children b5040cfea052
files autoload/unreal.vim
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/autoload/unreal.vim	Tue Jan 26 11:59:58 2021 -0800
+++ b/autoload/unreal.vim	Tue Jan 26 12:00:31 2021 -0800
@@ -206,12 +206,17 @@
 endfunction
 
 function! unreal#set_project(projname) abort
-    let g:unreal_project = a:projname
+    let l:clean_projname = trim(a:projname)
+    if !has_key(g:unreal_branch_projects, l:clean_projname)
+        call unreal#throw("No project '".l:clean_projname."' in the current branch. Branch projects are: ".string(keys(g:unreal_branch_projects)))
+    endif
+
+    let g:unreal_project = l:clean_projname
 
     let l:cached_proj_file = unreal#get_cache_path("LastProject.txt", 1) " Auto-create cache dir.
-    call writefile([a:projname], l:cached_proj_file)
+    call writefile([l:clean_projname], l:cached_proj_file)
 
-    call unreal#trace("Set UE project: ".a:projname)
+    call unreal#trace("Set UE project: ".l:clean_projname)
 endfunction
 
 function! unreal#get_branch_projects(branch_dir)