1. WEE 0.47 bug in search/replace all?

Hallo

giving this simplified file:

-- file crah_test.ex 
include blub.e as my 
 
puts(1,"blah"&"\n") 
puts(1,"bluh"&"\n") 
puts(1,"blih"&"\n") 
puts(1,"bloh"&"\n") 

Now trying to search/replace all, with 'puts' to 'my:puts' crashes WEE (only if 'whole word' is NOT selected).
It seems WEE runs into a endless loop.

A bruteforce fix works for me (file: wee.exw)

-------------------------------------- 
-- search and replace 
-------------------------------------- 
 
-- search for the phrase (sequence or pointer) and set the editor target 
-- returns 1 if found, otherwise 0 
global function search_find(sequence phrase, integer backward = 0) 
    if backward then 
	ssm(SCI_SETTARGETSTART, ssm(SCI_GETSELECTIONSTART)) 
	ssm(SCI_SETTARGETEND, 0) 
    else 
	ssm(SCI_SETTARGETSTART, ssm(SCI_GETSELECTIONEND)) 
	ssm(SCI_SETTARGETEND, ssm(SCI_GETTEXTLENGTH)) 
    end if 
     
    if ssm(SCI_SEARCHINTARGET, length(phrase), phrase) < 0 then 
	-- wrap around and search again 
	if not inreplaceall then --part of bruteforce fix 
	    if backward then 
		ssm(SCI_SETTARGETSTART, ssm(SCI_GETTEXTLENGTH)) 
	    else 
		ssm(SCI_SETTARGETSTART, 0) 
	    end if   
	end if  --part of bruteforce fix 
	if ssm(SCI_SEARCHINTARGET, length(phrase), phrase) < 0 then 
	    -- clear the target so search_replace won't do bad things 
	    ssm(SCI_SETTARGETSTART, 0) 
	    ssm(SCI_SETTARGETEND, 0) 
	    return 0 
	end if 
    end if 
    -- scroll to left side first 
    ssm(SCI_SETXOFFSET, 0) 
    -- set selection from target 
    ssm(SCI_SETSEL, ssm(SCI_GETTARGETSTART), ssm(SCI_GETTARGETEND)) 
     
    return 1 
end function 
--[...] 
-- replace all in document, saving the cursor position 
-- returns count of replacements made 
atom inreplaceall=0  --part of bruteforce fix 
global function search_replace_all(sequence what, sequence phrase) 
    integer 
	pos = ssm(SCI_GETCURRENTPOS), 
	anchor = ssm(SCI_GETANCHOR), 
	count = 0 
    inreplaceall=1  --part of bruteforce fix 
    -- save the current position to be restored later 
    ssm(SCI_SETANCHOR, 0) 
    ssm(SCI_SETCURRENTPOS, 0) 
    -- search until not found 
    ssm(SCI_BEGINUNDOACTION) 
    while search_find(what, 0) do 
        search_replace(phrase) 
        count += 1 
    end while 
    ssm(SCI_ENDUNDOACTION) 
    ssm(SCI_SETSEL, anchor, pos) 
    inreplaceall=0  --part of bruteforce fix 
    return count 
end function 

Andreas

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu