jugglerchris / textadept-vi

Customisation for the textadept editor to make it a bit more like vim.
MIT License
36 stars 5 forks source link

segfault on search (/, ?, * or #) in textadept-curses #10

Closed korakinos closed 9 years ago

korakinos commented 9 years ago

textadept-vi makes textadept-curses segfault on search (keys /, ?, * or #) for me. This is reproducable and clearly caused by textadept-vi, as it does not happen with it or both it and textredux disabled. It also does not happen in GUI textadept.

Here is a backtrace:

(gdb) bt
#0  0x00000000004d18a4 in SurfaceImpl::AlphaRectangle(PRectangle, int, ColourDesired, int, ColourDesired, int, int) ()
#1  0x00000000004a1542 in Indicator::Draw(Surface*, PRectangle const&, PRectangle const&) const ()
#2  0x0000000000498390 in ?? ()
#3  0x0000000000498535 in ?? ()
#4  0x000000000049c8b4 in EditView::DrawLine(Surface*, EditModel const&, ViewStyle const&, LineLayout const*, int, int, int, PRectangle, int, DrawPhase) ()
#5  0x000000000049d53e in EditView::PaintText(Surface*, EditModel const&, PRectangle, PRectangle, ViewStyle const&) ()
#6  0x0000000000474481 in Editor::Paint(Surface*, PRectangle) ()
#7  0x00000000004d4ef9 in ScintillaTerm::Refresh() ()
#8  0x00000000004d0e39 in scintilla_refresh ()
#9  0x00000000004db78a in ?? ()
#10 0x00000000004e2779 in main ()

I have textadept-vi and your fork of textredux cloned in my $HOME/.textadept/modules. I haven't tested all functionality (just installed), but at least basic movement and editing seems to be working.

Textadept version 7.8, running on Arch Linux.

My init.lua reads:

package.path = "/home/korakinos/.textadept/modules/textadept-vi/?.lua;" .. package.path
package.cpath = "/home/korakinos/.textadept/modules/textadept-vi/?.so;" .. package.cpath
_G.vi_mode = require 'vi_mode'
jugglerchris commented 9 years ago

Hi,

Thanks for the report, and sorry for the problems!

I don't see this on Ubuntu (12.04 or 14.10), so it may be specific to Arch. What version (in case it helps for me to install into a VM)?

It looks like it's crashing when trying to draw indicators (presumably when highlighting the results). Do you know if the indicators work at all for you?

I can come up with a simple bit of lua to add an indicator when I'm next at my PC if that helps.

Regards,

Chris

korakinos commented 9 years ago

Hi,

no worries, and thanks for helping!

I just noticed that my previous description was imprecise: The crash only happens when the search operation actually finds something. So "#" and "*" crash textadept-curses every time instantly, while "/" and "?" first open an input line at the bottom, and only crash after I enter a string, provided that string is present somewhere in the open buffer.

So yes, it seems likely that highlighting the search results is the problem.

I am not sure what "indicators" are in this context. Is it text highlighting/colors/...? There does indeed appear to be something wrong with that, as I don't have syntax highlighting in textadept-curses. (It works in GUI textadept.) I don't know how else to test, so if you could give me a Lua snippet or tell me what else I should do to test indicators, that would be great.

My textadept version is 7.8. As there is no textadept package in the Arch Linux repos, I built and installed it using this PKGBUILD script from the AUR: https://aur.archlinux.org/packages/te/textadept/PKGBUILD

If it helps, I can try to install 7.9.

As for Arch itself, it is a rolling release distro, so it doesn't have version numbers.

jugglerchris commented 9 years ago

Hi,

I put this into ~/.textadept/modules/indic.lua:

local M = {}

M.indic = _SCINTILLA.next_indic_number()

function M.test()
    buffer.indic_fore[M.indic] = 0xFF0000
    buffer.indic_style[M.indic] = _SCINTILLA.constants.INDIC_ROUNDBOX
    buffer.indic_alpha[M.indic] = 100
    -- Find all occurrences to highlight.
    buffer.indicator_current = M.indic
    buffer:indicator_clear_range(0, buffer.length)
    buffer:indicator_fill_range(1, 10)
end

And tested in a short text buffer by entering require('indic').test() from the Lua command entry; it highlights the first 10 characters (ok, except for the first).

Regards,

Chris

korakinos commented 9 years ago

When I run this command in ta-curses (no matter if with or without ta-vi), the window is split and the following message is displayed in the bottom half: [string "require('indic').test()"]:1: attempt to index a boolean value Nothing is highlighted.

The same happens in GUI ta, except there I get a new tab.

jugglerchris commented 9 years ago

Oops, sorry - the should be a return M at the end of indic.lua.

Chris

korakinos commented 9 years ago

Added return M. Now textadept-curses crashes on require('indic').test(), no matter if with or without textadept-vi and textredux.

So the good news is that there is nothing wrong with textadept-vi. Maybe the AUR installation script has bug—I'll try to look into it. (Really want to try out textadept, but need textadept-vi to overcome my vim addiction…)

Thanks!

korakinos commented 9 years ago

Turns out, something in the binaries from http://foicica.com/textadept/ is causing the problem! (The AUR install script is using them.) When I compile textadept from source, it doesn't crash and the highlighting works. I'm going to report this on the mailing list.