diff options
author | 2009-03-01 18:16:38 -0500 | |
---|---|---|
committer | 2009-03-01 18:16:38 -0500 | |
commit | 891bee0e40f31907e11333dadf7adf4b897250ee (patch) | |
tree | 5989e73850affd625f16c6185d7430f8798dd018 | |
parent | 91ad8cd1c8843d3e2b996b2af1884c3b128bf0bb (diff) | |
download | textadept-891bee0e40f31907e11333dadf7adf4b897250ee.tar.gz textadept-891bee0e40f31907e11333dadf7adf4b897250ee.zip |
Ignore null byte for specific Scintilla messages; use buffer:get_text() again.
-rw-r--r-- | core/ext/find.lua | 2 | ||||
-rw-r--r-- | core/ext/pm/ctags_browser.lua | 2 | ||||
-rw-r--r-- | core/file_io.lua | 4 | ||||
-rw-r--r-- | src/lua_interface.c | 2 |
4 files changed, 6 insertions, 4 deletions
diff --git a/core/ext/find.lua b/core/ext/find.lua index 018eaefe..064a7ddb 100644 --- a/core/ext/find.lua +++ b/core/ext/find.lua @@ -70,7 +70,7 @@ function find.find(text, next, flags, nowrap, wrapped) elseif flags < 16 then -- lua pattern search (forward search only) text = text:gsub('\\[abfnrtv\\]', escapes) - local buffer_text = buffer:text_range(0, buffer.length) + local buffer_text = buffer:get_text(buffer.length) local results = { buffer_text:find(text, buffer.anchor + increment) } if #results > 0 then result = results[1] diff --git a/core/ext/pm/ctags_browser.lua b/core/ext/pm/ctags_browser.lua index a0d8aaa2..23556f68 100644 --- a/core/ext/pm/ctags_browser.lua +++ b/core/ext/pm/ctags_browser.lua @@ -211,7 +211,7 @@ function perform_action(selected_item) if item.children then item = item.children end end if item.pattern then - local buffer_text = buffer:text_range(0, buffer.length) + local buffer_text = buffer:get_text(buffer.length) local search_text = item.pattern:gsub('\\/', '/') local s = buffer_text:find(search_text, 1, true) if s then diff --git a/core/file_io.lua b/core/file_io.lua index 9ad6dffd..7649f1ed 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -169,7 +169,7 @@ function set_encoding(buffer, encoding) local iconv = textadept.iconv local pos = buffer.current_pos local first_visible_line = buffer.first_visible_line - local text = buffer:text_range(0, buffer.length) + local text = buffer:get_text(buffer.length) text = iconv(text, buffer.encoding, 'UTF-8') text = iconv(text, encoding, buffer.encoding) text = iconv(text, 'UTF-8', encoding) @@ -189,7 +189,7 @@ function save(buffer) textadept.check_focused_buffer(buffer) if not buffer.filename then return save_as(buffer) end textadept.events.handle('file_before_save', buffer.filename) - local text = buffer:text_range(0, buffer.length) + local text = buffer:get_text(buffer.length) if buffer.encoding then local bom = buffer.encoding_bom or '' text = bom..textadept.iconv(text, buffer.encoding, 'UTF-8') diff --git a/src/lua_interface.c b/src/lua_interface.c index 7c219720..3a7e5e38 100644 --- a/src/lua_interface.c +++ b/src/lua_interface.c @@ -1016,6 +1016,8 @@ static int l_call_scintilla(lua_State *lua, ScintillaObject *sci, int msg, if (p1_type == tLENGTH) params[0] = len; return_string = reinterpret_cast<char*>(malloc(sizeof(char) * len + 1)); return_string[len] = '\0'; + if (msg == SCI_GETTEXT || msg == SCI_GETSELTEXT || msg == SCI_GETCURLINE) + len--; // Scintilla appends '\0' for these messages; compensate params[1] = reinterpret_cast<long>(return_string); } |