ソースを参照

Squashed 'src/ted2go/' changes from 06022fb5..1a0318f1

1a0318f1 Merge branch 'dev'
973de315 Merge branch 'master' into dev
3db71f33 Added "Find..." action to project browser - to searching in custom folders.
c42c6b7b Find - fixed crash when word is not found. Strore filter for findInFiles in settings.
48a1568a Added App.WaitIdle() in FIND logic to improve app responsibility.
6fed9b34 Fixed "find next / prev" behaviour.

git-subtree-dir: src/ted2go
git-subtree-split: 1a0318f18ab8c2e6bc3c7aa55fbef45eff16c18b
Mark Sibly 8 年 前
コミット
b471e634c6

+ 9 - 0
MainWindow.monkey2

@@ -200,12 +200,20 @@ Class MainWindowInstance Extends Window
 			_buildErrorsList.Visible=True
 		End
 		
+		' ProjectView
+		'
 		_projectView=New ProjectView( _docsManager,_buildActions )
+		' project opened
 		_projectView.ProjectOpened+=Lambda( dir:String )
 			AddRecentProject( dir )
 			SaveState()
 		End
+		' project closed
 		_projectView.ProjectClosed+=OnProjectClosed
+		' find in folder
+		_projectView.RequestedFindInFolder+=Lambda( folder:String )
+			_findActions.FindInFiles( folder )
+		End
 		
 		_fileActions=New FileActions( _docsManager )
 		_editActions=New EditActions( _docsManager )
@@ -1001,6 +1009,7 @@ Class MainWindowInstance Extends Window
 	
 		_docsManager.OpenDocument( path,True )
 		If lockIt Then _buildActions.LockBuildFile()
+		UpdateWindow( True )
 	End
 	
 	Method GetActionFind:Action()

+ 56 - 37
Prefs.monkey2

@@ -1,46 +1,56 @@
 Namespace ted2go
 
 
-Class Prefs
+Const Prefs:=New PrefsInstance
+
+Class PrefsInstance
 	
 	' AutoCompletion
-	Global AcEnabled:=True
-	Global AcKeywordsOnly:=False
-	Global AcShowAfter:=2
-	Global AcUseTab:=True
-	Global AcUseEnter:=False
-	Global AcUseSpace:=False
-	Global AcUseDot:=False
-	Global AcNewLineByEnter:=True
-	Global AcStrongFirstChar:=True
-	Global AcUseLiveTemplates:=True
+	Field AcEnabled:=True
+	Field AcKeywordsOnly:=False
+	Field AcShowAfter:=2
+	Field AcUseTab:=True
+	Field AcUseEnter:=False
+	Field AcUseSpace:=False
+	Field AcUseDot:=False
+	Field AcNewLineByEnter:=True
+	Field AcStrongFirstChar:=True
+	Field AcUseLiveTemplates:=True
 	'
-	Global MainToolBarVisible:=True
-	Global MainProjectTabsRight:=True
-	Global MainProjectIcons:=True
+	Field MainToolBarVisible:=True
+	Field MainProjectTabsRight:=True
+	Field MainProjectIcons:=True
 	'
-	Global IrcNickname:String
-	Global IrcServer:="irc.freenode.net"
-	Global IrcPort:=6667
-	Global IrcRooms:="#monkey2" '#mojox#mojo2d
-	Global IrcConnect:Bool=False
+	Field IrcNickname:String
+	Field IrcServer:="irc.freenode.net"
+	Field IrcPort:=6667
+	Field IrcRooms:="#monkey2" '#mojox#mojo2d
+	Field IrcConnect:Bool=False
 	'
-	Global EditorToolBarVisible:=False
-	Global EditorGutterVisible:=True
-	Global EditorShowWhiteSpaces:=False
-	Global EditorFontPath:String
-	Global EditorFontSize:=16
-	Global EditorShowEvery10LineNumber:=True
-	Global EditorCodeMapVisible:=True
-	Global EditorAutoIndent:=True
+	Field EditorToolBarVisible:=False
+	Field EditorGutterVisible:=True
+	Field EditorShowWhiteSpaces:=False
+	Field EditorFontPath:String
+	Field EditorFontSize:=16
+	Field EditorShowEvery10LineNumber:=True
+	Field EditorCodeMapVisible:=True
+	Field EditorAutoIndent:=True
 	'
-	Global SourceSortByType:=True
-	Global SourceShowInherited:=False
+	Field SourceSortByType:=True
+	Field SourceShowInherited:=False
 	'
-	Global MonkeyRootPath:String
-	Global IdeHomeDir:String
+	Field MonkeyRootPath:String
+	Field IdeHomeDir:String
 	
-	Function LoadState( json:JsonObject )
+	Property FindFilesFilter:String()
+		Return _findFilter
+	Setter( value:String )
+		
+		_findFilter=value
+		SaveLocalState()
+	End
+	
+	Method LoadState( json:JsonObject )
 		
 		If json.Contains( "irc" )
 			
@@ -100,7 +110,7 @@ Class Prefs
 		Endif
 	End
 	
-	Function SaveState( json:JsonObject )
+	Method SaveState( json:JsonObject )
 		
 		Local j:=New JsonObject
 		json["main"]=j
@@ -146,7 +156,7 @@ Class Prefs
 		
 	End
 	
-	Function LoadLocalState()
+	Method LoadLocalState()
 		
 		IdeHomeDir=HomeDir()+"Ted2Go/"
 		CreateDir( IdeHomeDir )
@@ -156,19 +166,22 @@ Class Prefs
 		
 		MonkeyRootPath=Json_GetString( json.Data,"rootPath","" )
 		If Not MonkeyRootPath.EndsWith( "/" ) Then MonkeyRootPath+="/"
+		
+		FindFilesFilter=Json_GetString( json.Data,"findFilesFilter","monkey2,txt" )
 	End
 	
-	Function SaveLocalState()
+	Method SaveLocalState()
 		
 		If Not MonkeyRootPath.EndsWith( "/" ) Then MonkeyRootPath+="/"
 		
 		Local json:=New JsonObject
 		json["rootPath"]=New JsonString( MonkeyRootPath )
+		json["findFilesFilter"]=New JsonString( FindFilesFilter )
 		json.Save( AppDir()+"state.json" )
 		
 	End
 	
-	Function GetCustomFontPath:String()
+	Method GetCustomFontPath:String()
 		
 		If Not EditorFontPath Return ""
 		If Not EditorFontPath.Contains( ".ttf" ) Return ""
@@ -181,10 +194,16 @@ Class Prefs
 		Return path
 	End
 	
-	Function GetCustomFontSize:Int()
+	Method GetCustomFontSize:Int()
 	
 		Return Max( EditorFontSize,6 ) '6 is a minimum
 	End
+	
+	
+	Private 
+	
+	Field _findFilter:String
+	
 End
 
 

+ 153 - 101
action/FindActions.monkey2

@@ -41,7 +41,9 @@ Class FindActions
 		replaceAll.Triggered=OnReplaceAll
 		
 		findInFiles=New Action( "Find in files..." )
-		findInFiles.Triggered=OnFindInFiles
+		findInFiles.Triggered=Lambda()
+			OnFindInFiles()
+		End
 		findInFiles.HotKey=Key.F
 		findInFiles.HotKeyModifiers=Modifier.Menu|Modifier.Shift
 		
@@ -66,9 +68,17 @@ Class FindActions
 		If Not entireProject Then OnFindNext( False )
 	End
 	
+	Method FindInFiles( folder:String )
+	
+		OnFindInFiles( folder )
+	End
+	
 	
 	Private
 	
+	Const NXT:=1
+	Const PREV:=-1
+	
 	Field _docs:DocumentManager
 	
 	Field _findDialog:FindDialog
@@ -79,23 +89,22 @@ Class FindActions
 	
 	Method OnFind()
 		
-		_findDialog.Show()
-		
 		Local tv:=_docs.CurrentTextView
 		If tv <> Null
+			_cursorPos=Min( tv.Cursor,tv.Anchor )
+			Local s:=""
 			If tv.Cursor <> tv.Anchor
 				Local min:=Min( tv.Cursor,tv.Anchor )
 				Local max:=Max( tv.Cursor,tv.Anchor )
-				Local s:=tv.Text.Slice( min,max )
-				_findDialog.SetInitialText( s )
+				s=tv.Text.Slice( min,max )
 			Endif
-			_cursorPos=Min( tv.Cursor,tv.Anchor )
+			_findDialog.SetInitialText( s )
 		Endif
+		
+		_findDialog.Show()
 	End
 	
-	Method OnFindInFiles()
-	
-		_findInFilesDialog.Show()
+	Method OnFindInFiles( folder:String=Null )
 	
 		Local tv:=_docs.CurrentTextView
 		If tv <> Null
@@ -106,6 +115,9 @@ Class FindActions
 				_findInFilesDialog.SetInitialText( s )
 			Endif
 		Endif
+		
+		_findInFilesDialog.CustomFolder=folder
+		_findInFilesDialog.Show()
 	End
 	
 	Field _storedTextView:TextView
@@ -114,14 +126,34 @@ Class FindActions
 	Field _storedEntireProject:Bool
 	Field _results:Stack<FileJumpData>
 	Field _resultIndex:Int=-1
+	Field _storedChanges:=0,_changesCounter:=0
+	Field _storedLastCursor:=-1
+	
+	Method OnTextChanged()
+		
+		_changesCounter+=1
+	End
+	
+	Method OnCursorChanged()
+		
+		Local tv:=_docs.CurrentTextView
+		If tv
+			_cursorPos=Min( tv.Cursor,tv.Anchor )
+		Endif
+	End
 	
 	Method OnFindNext( changeCursorPos:Bool=True )
 	
+		Local tv:=_docs.CurrentTextView
+		If Not tv Return
+		
 		Local doc:=_docs.CurrentDocument
-		If Not doc Return
 		
-		Local tv:=doc.TextView
-		If Not tv Return
+		tv.Document.TextChanged-=OnTextChanged
+		tv.Document.TextChanged+=OnTextChanged
+		
+		tv.CursorMoved-=OnCursorChanged
+		tv.CursorMoved+=OnCursorChanged
 		
 		Local what:=_findDialog.FindText
 		If Not what Return
@@ -137,11 +169,12 @@ Class FindActions
 		' when typing request word we should everytime find from current cursor
 		Local cursor:=_cursorPos
 		If changeCursorPos
-			cursor=Max( tv.Anchor,tv.Cursor )
+			cursor=Min( tv.Anchor,tv.Cursor )
 			_cursorPos=cursor
 		Endif
 		
 		Local theSame:=(what=_storedWhat And sens=_storedCaseSens And entire=_storedEntireProject)
+		theSame = theSame And _storedChanges=_changesCounter
 		
 		If Not entire Then theSame=theSame And tv=_storedTextView
 		
@@ -149,113 +182,130 @@ Class FindActions
 		_storedTextView=tv
 		_storedCaseSens=sens
 		_storedEntireProject=entire
+		_storedChanges=_changesCounter
 		
 		If Not theSame Then _results=Null
 		
-		If _results
-			' use current search results
-			If Not _results.Empty
-				_resultIndex=(_resultIndex+1) Mod _results.Length
-			Endif
-			
-		Else
+		If Not _results
 			
 			_resultIndex=-1
+			_storedLastCursor=-1
 			
 			' start new search
 			If entire
 				
-				Local proj:=""
-				For Local p:=Eachin _projView.OpenProjects
-					If doc.Path.Contains( p )
-						proj=p
-						Exit
-					Endif
-				End
-				Local map:=FindInProject( what,proj,sens )
-				If map
-					CreateResultTree( _findConsole.RootNode,map,what,proj )
-					MainWindow.ShowFindResults()
-				Endif
+				New Fiber( Lambda()
 				
-				If Not map.Empty
-					
-					_results=New Stack<FileJumpData>
+					Local proj:=""
+					For Local p:=Eachin _projView.OpenProjects
+						If doc.Path.Contains( p )
+							proj=p
+							Exit
+						Endif
+					End
+					Local map:=FindInProject( what,proj,sens )
+					If map
+						CreateResultTree( _findConsole.RootNode,map,what,proj )
+						MainWindow.ShowFindResults()
+					Endif
 					
-					' make current opened document as a first results
-					Local curPath:=_docs.CurrentDocument ? _docs.CurrentDocument.Path Else ""
-					If curPath
-						Local vals:=map[curPath]
-						If vals
-							_results.AddAll( vals )
-							map.Remove( curPath )
+					If Not map.Empty
+						
+						_results=New Stack<FileJumpData>
+						
+						' make current opened document as a first results
+						Local curPath:=_docs.CurrentDocument ? _docs.CurrentDocument.Path Else ""
+						If curPath
+							Local vals:=map[curPath]
+							If vals
+								_results.AddAll( vals )
+								map.Remove( curPath )
+							Endif
 						Endif
+						
+						For Local items:=Eachin map.Values
+							_results.AddAll( items )
+						End
+						
 					Endif
 					
-					For Local items:=Eachin map.Values
-						_results.AddAll( items )
-					End
-					_resultIndex=0
-				Endif
+					Jump( NXT )
+				End )
 				
-			Else
+				Return
 				
-				_results=FindInFile( "",what,sens,tv.Document )
+			Else
 				
-				If Not _results.Empty
-					' take the first result accordingly to cursor
-					For Local i:=0 Until _results.Length
-						Local jump:=_results[i]
-						If jump.pos>=cursor
-							_resultIndex=i
-							Exit
-						Endif
-					Next
-					If _resultIndex=-1 Then _resultIndex=0 ' take from top of doc
-				Endif
+				_results=FindInFile( doc.Path,what,sens,tv.Document )
 				
 			Endif
 			
 		Endif
 		
-		If _resultIndex>=0
-			
-			Local jump:=_results[_resultIndex]
-			
-			If _storedEntireProject
-				MainWindow.OpenDocument( jump.path )
-				tv=_docs.CurrentTextView
-			Endif
-			
-			If tv Then tv.SelectText( jump.pos,jump.pos+jump.len )
-			
-		Endif
+		Jump( NXT )
 		
 	End
 	
-	Method OnFindPrevious()
+	Method Jump( nxtOrPrev:Int )
 		
-		If _resultIndex>=0
-			
-			Local tv:=_docs.CurrentTextView
-			If Not tv Return
-			
+		If Not _results Or _results.Length=0 Return
+		
+		If nxtOrPrev=NXT
+			_resultIndex=(_resultIndex+1) Mod _results.Length
+		Else
 			_resultIndex-=1
 			If _resultIndex<0 Then _resultIndex=_results.Length-1
-			
-			Local jump:=_results[_resultIndex]
-			
-			If _storedEntireProject
-				MainWindow.OpenDocument( jump.path )
-				tv=_docs.CurrentTextView
+		Endif
+		
+		Local jump:=_results[_resultIndex]
+		
+		If _storedEntireProject
+			MainWindow.OpenDocument( jump.path )
+		Endif
+	
+		Local tv:=_docs.CurrentTextView
+		If tv
+			Local i:=FixResultIndexByCursor( _docs.CurrentDocument,_resultIndex,nxtOrPrev )
+			If i<>_resultIndex
+				_resultIndex=i
+				jump=_results[_resultIndex]
 			Endif
-			
-			If tv Then tv.SelectText( jump.pos,jump.pos+jump.len )
-			
+			tv.SelectText( jump.pos,jump.pos+jump.len )
+			_storedLastCursor=Min( tv.Cursor,tv.Anchor )
 		Endif
 	
 	End
 	
+	Method FixResultIndexByCursor:Int( doc:Ted2Document,index:Int,nxtOrPrev:Int )
+		
+		Local tv:=doc.TextView
+		Local theSameDoc:=(tv=_storedTextView)
+		Local cursor:=Min( tv.Cursor,tv.Anchor )
+		Local findFromCursor:=(theSameDoc And cursor<>_storedLastCursor)
+		
+		If Not findFromCursor Return index
+		
+		' take the first result accordingly to cursor
+		If nxtOrPrev=NXT
+			For Local i:=0 Until _results.Length
+				Local jump:=_results[i]
+				If jump.path=doc.Path And jump.pos>=cursor Return i
+			Next
+			Return 0
+		Else
+			For Local i:=_results.Length-1 To 0 Step -1
+				Local jump:=_results[i]
+				If jump.path=doc.Path And jump.pos<=cursor Return i
+			Next
+			Return _results.Length-1
+		Endif
+	End
+	
+	Method OnFindPrevious()
+		
+		Jump( PREV )
+	End
+	
 	Method OnFindAllInFiles()
 	
 		If Not _findInFilesDialog.FindText
@@ -268,23 +318,20 @@ Class FindActions
 			Return
 		Endif
 		
-		_findInFilesDialog.Hide()
+		'_findInFilesDialog.Hide()
 		MainWindow.ShowFindResults()
 		
-		App.Idle+=Lambda()
+		New Fiber( Lambda()
+		
+			Local what:=_findInFilesDialog.FindText
+			Local proj:=_findInFilesDialog.SelectedProject
+			Local sens:=_findInFilesDialog.CaseSensitive
+			Local filter:=_findInFilesDialog.FilterText
 			
-			New Fiber( Lambda()
+			Local result:=FindInProject( what,proj,sens,filter )
 			
-				Local what:=_findInFilesDialog.FindText
-				Local proj:=_findInFilesDialog.SelectedProject
-				Local sens:=_findInFilesDialog.CaseSensitive
-				Local filter:=_findInFilesDialog.FilterText
-				
-				Local result:=FindInProject( what,proj,sens,filter )
-				
-				If result Then CreateResultTree( _findConsole.RootNode,result,what,proj )
-			End)
-		End
+			If result Then CreateResultTree( _findConsole.RootNode,result,what,proj )
+		End)
 		
 	End
 	
@@ -302,11 +349,11 @@ Class FindActions
 		
 		Local files:=New Stack<String>
 		Utils.GetAllFiles( projectPath,exts,files )
-		
 		Local len:=what.Length
 		
 		Local result:=New StringMap<Stack<FileJumpData>>
 		
+		'Local counter:=1
 		Local doc:=New TextDocument 'use it to get line number
 		For Local f:=Eachin files
 		
@@ -337,6 +384,11 @@ Class FindActions
 			
 			If Not items.Empty Then result[f]=items
 			
+			'If counter Mod 10 = 0
+			'	' process 10 files per frame to save app responsibility
+			'	App.WaitIdle()
+			'Endif
+			
 		Next
 		
 		Return result

+ 27 - 3
dialog/FindInFilesDialog.monkey2

@@ -14,7 +14,7 @@ Class FindInFilesDialog Extends DialogExt
 		
 		_projList=New ListView
 		_projList.MaxSize=New Vec2i( 500,120 )
-		_filterField=New TextField( "monkey2,txt" )
+		_filterField=New TextField( Prefs.FindFilesFilter )
 		
 		_caseSensitive=New CheckButton( "Case sensitive" )
 		_caseSensitive.Layout="float"
@@ -39,7 +39,11 @@ Class FindInFilesDialog Extends DialogExt
 		
 		ContentView=_docker
 		
-		AddAction( actions.findAllInFiles )
+		Local findAll:=AddAction( actions.findAllInFiles.Text )
+		findAll.Triggered=Lambda()
+			actions.findAllInFiles.Trigger()
+			Prefs.FindFilesFilter=_filterField.Text.Trim()
+		End
 		
 		Local close:=AddAction( "Close" )
 		SetKeyAction( Key.Escape,close )
@@ -48,21 +52,40 @@ Class FindInFilesDialog Extends DialogExt
 		_findField.Activated+=_findField.MakeKeyView
 		
 		Deactivated+=MainWindow.UpdateKeyView
-				
+		
 		OnShow+=Lambda()
+			
+			If CustomFolder Return
+			
 			Local projs:=projView.OpenProjects
 			If Not projs Return
+			
 			_projList.RemoveAllItems()
+			
 			Local sel:ListView.Item=Null
 			For Local p:=Eachin projs
 				Local it:=_projList.AddItem( p )
 				If Not sel Then sel=it
 			Next
 			_projList.Selected=sel
+			
 		End
 		
 	End
 	
+	Property CustomFolder:String()
+		
+		Return _customFolder
+		
+	Setter( value:String )
+		
+		_customFolder=value
+		If Not _customFolder Return
+		
+		_projList.RemoveAllItems()
+		_projList.Selected=_projList.AddItem( _customFolder )
+	End
+	
 	Property FindText:String()
 	
 		Return _findField.Text
@@ -97,5 +120,6 @@ Class FindInFilesDialog Extends DialogExt
 	Field _caseSensitive:CheckButton
 	Field _projList:ListView
 	Field _docker:DockingView
+	Field _customFolder:String
 	
 End

+ 8 - 1
parser/Monkey2Parser.monkey2

@@ -165,7 +165,14 @@ Class Monkey2Parser Extends CodeParserPlugin
 			Local imports:=jobj["imports"].ToArray()
 			For Local jfile:=Eachin imports
 				Local file:=jfile.ToString()
-				If file.StartsWith( "<" ) Or Not file.EndsWith( ".monkey2" ) Continue 'skip modules and not .monkey2
+				If file.StartsWith( "<" ) Continue 'skip modules
+				If Not file.EndsWith( ".monkey2" )
+					If FileExists( folder+file+".monkey2") 
+						file+=".monkey2"
+					Else
+						Continue 'skip not .monkey2
+					Endif
+				Endif
 				file=folder+file
 				'Print "parse import: "+file+"  mod: "+Int(isModule)
 				ParseFile( file,file,isModule )

+ 5 - 4
utils/Utils.monkey2

@@ -87,9 +87,9 @@ Class Utils
 		Return result
 	End
 	
-	Function GetAllFiles( rootDir:String,filterExts:String[],target:Stack<String> )
+	Function GetAllFiles( rootDir:String,filterExts:String[],target:Stack<String>,idleAppEachN:Int=-1 )
 		
-		GetAllFilesInternal( rootDir,filterExts,target )
+		GetAllFilesInternal( rootDir,filterExts,target,idleAppEachN )
 	End
 	
 	#Rem monkeydoc If 'any' is true - check at least one starts, else - check all.
@@ -148,10 +148,12 @@ Class Utils
 	Method New()
 	End
 	
-	Function GetAllFilesInternal( dir:String,filterExts:String[],target:Stack<String> )
+	Function GetAllFilesInternal( dir:String,filterExts:String[],target:Stack<String>,idleAppEachN:Int=-1 )
 		
 		Local files:=LoadDir( dir )
+		Local ii:=0
 		For Local f:=Eachin files
+			If idleAppEachN>0 And ii Mod idleAppEachN = 0 Then App.WaitIdle()
 			f=dir+f
 			If GetFileType( f )=FileType.Directory
 				GetAllFilesInternal( f+"/",filterExts,target )
@@ -166,7 +168,6 @@ Class Utils
 	
 End
 
-
 Function FileExists:Bool( path:String )
 	
 	Return GetFileType( path )=FileType.File

+ 14 - 7
view/ProjectView.monkey2

@@ -8,6 +8,8 @@ Class ProjectView Extends ScrollView
 	
 	Field ProjectOpened:Void( dir:String )
 	Field ProjectClosed:Void( dir:String )
+	
+	Field RequestedFindInFolder:Void( folder:String )
 
 	Method New( docs:DocumentManager,builder:IModuleBuilder )
 	
@@ -65,9 +67,9 @@ Class ProjectView Extends ScrollView
 			Select GetFileType( path )
 			Case FileType.Directory
 			
-				menu.AddAction( "Open on Desktop" ).Triggered=Lambda()
+				menu.AddAction( "Find..." ).Triggered=Lambda()
 				
-					requesters.OpenUrl( path )
+					RequestedFindInFolder( path )
 				End
 				
 				menu.AddSeparator()
@@ -84,7 +86,6 @@ Class ProjectView Extends ScrollView
 						Endif
 					End
 					d.ShowModal()
-					Return
 				End
 				
 				menu.AddSeparator()
@@ -99,7 +100,6 @@ Class ProjectView Extends ScrollView
 					CreateFileInternal( tpath )
 					
 					browser.Refresh()
-					Return
 				End
 				
 				menu.AddAction( "New folder" ).Triggered=Lambda()
@@ -120,7 +120,6 @@ Class ProjectView Extends ScrollView
 					Endif
 					
 					browser.Refresh()
-					Return
 				End
 				
 				menu.AddAction( "Delete" ).Triggered=Lambda()
@@ -205,6 +204,14 @@ Class ProjectView Extends ScrollView
 					Endif
 				Endif
 				
+				menu.AddSeparator()
+				
+				menu.AddAction( "Open on Desktop" ).Triggered=Lambda()
+				
+					requesters.OpenUrl( path )
+				End
+				
+				
 			Case FileType.File
 			
 				menu.AddAction( "Open on Desktop" ).Triggered=Lambda()
@@ -217,8 +224,8 @@ Class ProjectView Extends ScrollView
 				menu.AddAction( "Rename" ).Triggered=Lambda()
 				
 					Local oldName:=StripDir( path )
-					Local name:=RequestString( "Enter new name:","Ranaming '"+oldName+"'" )
-					If name=oldName Return
+					Local name:=RequestString( "Enter new name:","Ranaming '"+oldName+"'",oldName )
+					If Not name Or name=oldName Return
 					
 					Local newPath:=ExtractDir( path )+name
 					If CopyFile( path,newPath )