Author Topic: stack when performing a "replace in files"  (Read 390 times)

rowbearto

  • Senior Community Member
  • Posts: 1880
  • Hero Points: 122
stack when performing a "replace in files"
« on: March 04, 2021, 07:27:28 pm »
It happens when I click the "Replace All" button, using the "Replace" button works (but then I have to approve each replacement)

Code: [Select]
Stack trace written to file: /tmp/vsstack.rbresali
 Recursion in search function not supported
tags.ex 62314 _generic_regex_proc_search(^[ \t]*(#|((function:b)<<<NAME>>>[ \t]*((\([ \t]*\)):0,1))|((function:b|)<<<NAME>>>[ \t]*((\([ \t]*\))))),[a-zA-Z_$][a-zA-Z_$0-9]@,1,func,<empty>,<empty>)
   p_window_id: 559
   p_object: OI_EDITOR
   p_name:
slickc.ex 23961 bourneshell_proc_search1([a-zA-Z_$][a-zA-Z_$0-9]@,1,bourneshell,0,11174)   p_window_id: 1127   p_object: OI_EDITOR   p_name:
slickc.ex 22382 _EmbeddedProcSearch(&8849,[a-zA-Z_$][a-zA-Z_$0-9]@,1,bourneshell,,)   p_window_id: 1127   p_object: OI_EDITOR   p_name:
slickc.ex 24471 bourneshell_proc_search([a-zA-Z_$][a-zA-Z_$0-9]@,1,bourneshell,,)   p_window_id: 1127   p_object: OI_EDITOR   p_name:
context.ex 12546 context:_UpdateContext3(1,1)   p_window_id: 1127   p_object: OI_EDITOR   p_name:
context.ex 13279 context:_UpdateContext2(1,1)   p_window_id: 1127   p_object: OI_EDITOR   p_name:
context.ex 5777 _UpdateContext(1,1,1)   p_window_id: 1127   p_object: OI_EDITOR   p_name:
SearchResults.ex 3441 se.search.SearchResults.buildContextTable(
   1:   ._typename()=se.search.SearchResults
   1:   .m-last-file=/home/rbresali/v/git/rbresali-work2/src/mc5u/MC5U/Tools/packaging/gen_common.sh
   1:   .m-match-line=105
   1:   .m-match-col=28
   1:   .m-prefix-width=-1
   1:   .m-last-line=-1
   1:   .m-last-col=-1
   1:   .m-top-line=1
   1:   .m-mfflags=40960
   1:   .m-wid=282
   1:   .m-grepid=8
   1:   .m-context-id=-1
   1:   .m-context-level=-1
   1:   .m-last-buf-id=-1
   1:   .m-before-match-lines=0
   1:   .m-after-match-lines=0
   1:   .m-context-enabled=0
   1:   .m-after-lines=<empty>
   1:   .m-context-stack[0]=0
   1:   .m-context-stack[1]=3
   p_window_id: 1127
   p_object: OI_EDITOR
   p_name:
SearchResults.ex 4826 se.search.SearchResults.insertCurrentReplace(
   1:   ._typename()=se.search.SearchResults
   1:   .m-last-file=/home/rbresali/v/git/rbresali-work2/src/mc5u/MC5U/Tools/packaging/gen_common.sh
   1:   .m-match-line=105
   1:   .m-match-col=28
   1:   .m-prefix-width=-1
   1:   .m-last-line=-1
   1:   .m-last-col=-1
   1:   .m-top-line=1
   1:   .m-mfflags=40960
   1:   .m-wid=282
   1:   .m-grepid=8
   1:   .m-context-id=-1
   1:   .m-context-level=-1
   1:   .m-last-buf-id=-1
   1:   .m-before-match-lines=0
   1:   .m-after-match-lines=0
   1:   .m-context-enabled=0
   1:   .m-after-lines=<empty>
   1:   .m-context-stack[0]=0
   1:   .m-context-stack[1]=3
   p_window_id: 1127
   p_object: OI_EDITOR
   p_name:
guireplace.ex 723 guireplace:replaceCallback(@513182)   p_window_id: 1127   p_object: OI_EDITOR   p_name:
guireplace.ex 789 guireplace:_qreplace_all(modulevariant,moduletype,@*E*+@H,0,@513182)   p_window_id: 1127   p_object: OI_EDITOR   p_name:
guireplace.ex 351 gui_replace2(modulevariant,moduletype,*E*+@H,1,1,@513182,0,1)   p_window_id: 1127   p_object: OI_EDITOR   p_name:
mfsearch.ex 5647 mfsearch:_mfreplaceProcessFile(
   1:   ._typename()=MFREPLACE-ARGS
   1:   .AskAboutMissingFiles=1
   1:   .list-view-id=1127
   1:   .orig-view-id=704
   1:   .search-string=modulevariant
   1:   .replace-string=moduletype
   1:   .options=E*+@H
   1:   .doGrep=1
   1:   .doDiff=0
   1:   .doMFUndo=1
   1:   .leaveFileOpen=0
   1:   .MFUndoStarted=1
   1:   .edit-view-id=559
   1:   .NofFileMatches=2
   1:   .go-save-all=0
   1:   .prompt-save=1
   1:   .results._typename()=se.search.SearchResults
   1:   .results.m-last-file=/home/rbresali/v/git/rbresali-work2/src/mc5u/MC5U/Tools/packaging/gen_common.sh
   1:   .results.m-match-line=105
   1:   .results.m-match-col=28
   1:   .results.m-prefix-width=-1
   1:   .results.m-last-line=-1
   1:   .results.m-last-col=-1
   1:   .results.m-top-line=1
   1:   .results.m-mfflags=40960
   1:   .results.m-wid=282
   1:   .results.m-grepid=8
   1:   .results.m-context-id=-1
   1:   .results.m-context-level=-1
   1:   .results.m-last-buf-id=-1
   1:   .results.m-before-match-lines=0
   1:   .results.m-after-match-lines=0
   1:   .results.m-context-enabled=0
   1:   .results.m-after-lines=<empty>
   1:   .results.m-context-stack[0]=0
   1:   .results.m-context-stack[1]=3
   1:   .Nofchanges=2
   1:   .TotalFilesSearched=2
   1:   .file-stats._typename()=MFFIND-FILE-STATS
   1:   .file-stats.max-file-size=0
   1:   .file-stats.modified-file-op=0
   1:   .file-stats.modified-file-time1=0
   1:   .file-stats.modified-file-time2=0
   2:   /home/rbresali/v/git/rbresali-work2/src/mc5u/MC5U/Tools/packaging/gen_common.sh
   3:   -1
   p_window_id: 1127
   p_object: OI_EDITOR
   p_name:
 0x0x79e980 -grep-file-list(1127,0,0,modulevariant,E*+,&18005,
   7:   ._typename()=MFREPLACE-ARGS
   7:   .AskAboutMissingFiles=1
   7:   .list-view-id=1127
   7:   .orig-view-id=704
   7:   .search-string=modulevariant
   7:   .replace-string=moduletype
   7:   .options=E*+@H
   7:   .doGrep=1
   7:   .doDiff=0
   7:   .doMFUndo=1
   7:   .leaveFileOpen=0
   7:   .MFUndoStarted=1
   7:   .edit-view-id=559
   7:   .NofFileMatches=2
   7:   .go-save-all=0
   7:   .prompt-save=1
   7:   .results._typename()=se.search.SearchResults
   7:   .results.m-last-file=/home/rbresali/v/git/rbresali-work2/src/mc5u/MC5U/Tools/packaging/gen_common.sh
   7:   .results.m-match-line=105
   7:   .results.m-match-col=28
   7:   .results.m-prefix-width=-1
   7:   .results.m-last-line=-1
   7:   .results.m-last-col=-1
   7:   .results.m-top-line=1
   7:   .results.m-mfflags=40960
   7:   .results.m-wid=282
   7:   .results.m-grepid=8
   7:   .results.m-context-id=-1
   7:   .results.m-context-level=-1
   7:   .results.m-last-buf-id=-1
   7:   .results.m-before-match-lines=0
   7:   .results.m-after-match-lines=0
   7:   .results.m-context-enabled=0
   7:   .results.m-after-lines=<empty>
   7:   .results.m-context-stack[0]=0
   7:   .results.m-context-stack[1]=3
   7:   .Nofchanges=2
   7:   .TotalFilesSearched=2
   7:   .file-stats._typename()=MFFIND-FILE-STATS
   7:   .file-stats.max-file-size=0
   7:   .file-stats.modified-file-op=0
   7:   .file-stats.modified-file-time1=0
   7:   .file-stats.modified-file-time2=0
   8:   &18004
   9:   40960
   p_window_id: 1127
   p_object: OI_EDITOR
   p_name:
mfsearch.ex 6905 mfsearch:_mfreplace2util(modulevariant,moduletype,E*+,+t /home/rbresali/v/git/rbresali-work2/src/mc5u/MC5U/,0,0,
   7:   CMakeLists.txt;*.cmake;buildall.sh;gen_common.sh;print_brcm_versions.py;getdcoversion.py   8:   <Default Excludes>;*.log;local-objs/
   9:   1
   10:   40960
   11:   8
   12:   
   p_window_id: 1127
   p_object: OI_EDITOR
   p_name:
mfsearch.ex 1035 _mfreplace(modulevariant,moduletype,E*+,+t /home/rbresali/v/git/rbresali-work2/src/mc5u/MC5U/,,0,0,
   8:   CMakeLists.txt;*.cmake;buildall.sh;gen_common.sh;print_brcm_versions.py;getdcoversion.py   9:   <Default Excludes>;*.log;local-objs/
   10:   1
   11:   8192
   12:   8
   13:   0
   14:   
   p_window_id: 704
   p_object: OI_EDITOR
   p_name:
mfsearch.ex 748 _mfreplace2(modulevariant,moduletype,E*,+t /home/rbresali/v/git/rbresali-work2/src/mc5u/MC5U/,CMakeLists.txt;*.cmake;buildall.sh;gen_common.sh;print_brcm_versions.py;getdcoversion.py,
   6:   <Default Excludes>;*.log;local-objs/   7:   8192
   8:   8
   9:   0
   p_window_id: 531
   p_object: OI_COMBO_BOX
   p_name: _replacestring
tbfind.ex 27707 tbfind:_replace_in_files(modulevariant,moduletype,E*,+t /home/rbresali/v/git/rbresali-work2/src/mc5u/MC5U/,
   5:   CMakeLists.txt;*.cmake;buildall.sh;gen_common.sh;print_brcm_versions.py;getdcoversion.py   6:   <Default Excludes>;*.log;local-objs/
   7:   8192
   8:   8
   9:   0
   p_window_id: 531
   p_object: OI_COMBO_BOX
   p_name: _replacestring
tbfind.ex 28570 tbfind:_begin_replace(*,0)   p_window_id: 531   p_object: OI_COMBO_BOX   p_name: _replacestring
tbfind.ex 28708 _tbfind_form._replaceall_btn.lbutton_up()   p_window_id: 1104   p_object: OI_COMMAND_BUTTON   p_name: _replaceall_btn
« Last Edit: March 04, 2021, 07:29:12 pm by rowbearto »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5768
  • Hero Points: 460
Re: stack when performing a "replace in files"
« Reply #1 on: March 05, 2021, 05:23:46 am »
Reproduced

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5768
  • Hero Points: 460
Re: stack when performing a "replace in files"
« Reply #2 on: March 05, 2021, 03:50:34 pm »
There's a limitation where languages with <langid>_proc_search functions do not support outputting context information in certain situations. The bug here is that for this specific case, the error check is missing. Context information does get output for Find in Files but ONLY IF the buffer isn't already loaded and the search is being done by the second instance of SlickEdit. It won't be output for Replace in Files for languages with <langid>_proc_search functions (like Shell scripts).

I've checked in a hot fix for this.

I might try to work around this limitation for v26. <langid>_proc_search functions can be slow but when you want context information you should get it. Improving this will require changing some complicated non-reentrant code.

rowbearto

  • Senior Community Member
  • Posts: 1880
  • Hero Points: 122
Re: stack when performing a "replace in files"
« Reply #3 on: March 05, 2021, 03:58:11 pm »
Thanks Clark! +1

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5768
  • Hero Points: 460
Re: stack when performing a "replace in files"
« Reply #4 on: March 05, 2021, 05:38:19 pm »
I'm not sure it's a good idea for SlickEdit to support context output for languages with <langid>_proc_search functions.

Only the start of the function (or other type) is known. In other words, SlickEdit won't know where the end of the function or type is. This means the context information could be incorrect.

Code: [Select]
#!/bin/bash
#
# Do a multi file search for "echo" on this file
# and you'll see what I mean.
# Make sure you don't already have this file open.
#
function myfunc {
  echo "myfunc"
}
echo "myfunc"
echo "myfunc"

I suspect this might be why context output was being disabled and it may be a bug that this is not being disabled in all cases. Try it out and you tell me if you don't mind incorrect context output.