[code][textadept] Initialization issue II

From: Gabriel Dubatti <gdubatti.att.gmail.com>
Date: Thu, 9 Nov 2017 11:23:26 -0300

Hi,

     I put some time into debugging this, and found that the issue
appears after recompiling the 9.6 version (without any change) in Ubuntu
Mate 17.10 following the compilation instructions (build-essential and
libgtk2-0.dev).

     I can not reproduce the issue with the downloaded version (9.6) so
it could be a gcc issue (version 7.2) or a library problem.

     Just for reference,  I'm using the following test code in init.lua:

--------------------------------------

local log_ev={}

function log_event(event)
   local line= os.date('%c')..": "..event.."\n"
   log_ev[#log_ev+1]= line
end

keys.csf5 = function()
   buffer.new()
   log_event("DUMP\n")
   for i=1,#log_ev do
     buffer:append_text(log_ev[i])
   end
end
events.connect(events.RESET_BEFORE, log_event("RESET_BEFORE"))
events.connect(events.RESET_AFTER, log_event("RESET_AFTER"))
log_event("START")

function EVinitialize()
   for _, buff in ipairs(_BUFFERS) do
     if buff.filename then
       log_event("filename= ".. buff.filename)
     else
       log_event("filename= NIL")
     end
     local line= buff:get_line(0)
     if line then
       log_event("line0= ".. line)
     else
       log_event("line0= NIL")
     end
   end
end
events.connect(events.INITIALIZED, EVinitialize)

---------------------------------------

To test: Open a bunch of files, close TA, open it again and press
Ctrl+Shift+F5 to show the log:

When everything works fine you'll get something like:

--------------

jue 09 nov 2017 10:52:16 -03: RESET_BEFORE
jue 09 nov 2017 10:52:16 -03: RESET_AFTER
jue 09 nov 2017 10:52:16 -03: START
jue 09 nov 2017 10:52:16 -03: filename=
/home/user/Descargas/textadept_9.6.x86_64/README.md
jue 09 nov 2017 10:52:16 -03: line0= # Textadept

jue 09 nov 2017 10:52:16 -03: filename=
/home/user/Descargas/textadept_9.6.x86_64/TECHNOLOGY.md
jue 09 nov 2017 10:52:16 -03: line0= # Technology

jue 09 nov 2017 10:52:16 -03: filename=
/home/user/Descargas/textadept_9.6.x86_64/THANKS.md
jue 09 nov 2017 10:52:16 -03: line0= # Thanks

.....

jue 09 nov 2017 10:52:18 -03: DUMP

--------------

When the issue appears, I get empty "line0"s (all except the last one).

After that, if I run reset() I get:

----------------

jue 09 nov 2017 10:54:26 -03: RESET_BEFORE
jue 09 nov 2017 10:54:26 -03: RESET_AFTER
jue 09 nov 2017 10:54:26 -03: START
jue 09 nov 2017 10:54:27 -03: filename= /home/user/.textadept/init.lua
jue 09 nov 2017 10:54:27 -03: line0= reset()
jue 09 nov 2017 10:54:27 -03: filename= /home/user/.textadeptGG/log.lua
jue 09 nov 2017 10:54:27 -03: line0= reset()
jue 09 nov 2017 10:54:27 -03: filename=
/home/user/.textadeptGG/modules/project/proj_data.lua
jue 09 nov 2017 10:54:27 -03: line0= reset()
jue 09 nov 2017 10:54:27 -03: filename=
/home/user/.textadeptGG/modules/project/init.lua
jue 09 nov 2017 10:54:27 -03: line0= reset()
jue 09 nov 2017 10:54:27 -03: filename=
/home/user/.textadeptGG/modules/project/proj_cmd.lua
jue 09 nov 2017 10:54:27 -03: line0= reset()
jue 09 nov 2017 10:54:27 -03: filename=
/home/user/.textadeptGG/modules/project/proj_ctags.lua
jue 09 nov 2017 10:54:27 -03: line0= reset()
jue 09 nov 2017 10:54:27 -03: filename=
/home/user/.textadeptGG/modules/project/proj_diff.lua
jue 09 nov 2017 10:54:27 -03: line0= reset()
jue 09 nov 2017 10:54:27 -03: filename=
/home/user/.textadeptGG/modules/project/proj_menu.lua
jue 09 nov 2017 10:54:27 -03: line0= reset()
jue 09 nov 2017 10:54:27 -03: filename=
/home/user/.textadeptGG/modules/project/proj_ui.lua
jue 09 nov 2017 10:54:27 -03: line0= reset()
jue 09 nov 2017 10:54:27 -03: filename= NIL
jue 09 nov 2017 10:54:27 -03: line0= jue 09 nov 2017 10:54:17 -03:
RESET_BEFORE

jue 09 nov 2017 10:54:28 -03: DUMP

----------------

Cheers,

Gabriel

-------- Mensaje reenviado --------
Asunto: [code][textadept] Initialization issue
Fecha: Wed, 8 Nov 2017 16:35:04 -0300
De: Gabriel Dubatti <gdubatti.att.gmail.com>
Responder a: gdubatti.att.gmail.com
Organización: Ing. Dubatti
Para: code.att.foicica.com <code.att.foicica.com>

Hi,

     I'm compiling textadept with my toolbar code in ubuntu mate 17.10
and found some issues during the startup sequence.

     I analyze the first line of each file to determine if the file is a
project or not. I do this at start-up and every time a file is opened.

     The code always worked well on Linux and Windows, but I see that in
the last version of Ubuntu Mate the project file is sometimes not detected.

     Adding some debug I found that in the INITIALIZED event, every
previously opened buffer is created with the appropriate file name, but
when I call "buffer:get_line(0)"

     some files return "" instead of the first line content.

     This sometimes works well, and sometimes not.

     It's like the files were opened in asynchronous mode and sometimes
they are in memory when I call get_line(), and sometimes not.

     Is it OK to call get_line(0) for the current open buffers in the
INITIALIZED event?

     Best regards,
     Gabriel

PS: sorry for the forwarding, I forgot the [tags] on the subject of the
email

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Thu 09 Nov 2017 - 09:23:26 EST

This archive was generated by hypermail 2.2.0 : Fri 10 Nov 2017 - 06:46:09 EST