diff options
author | 2008-03-04 22:05:52 -0500 | |
---|---|---|
committer | 2008-03-04 22:05:52 -0500 | |
commit | e672ee07c4b97fa205db0a5c75f69d9f8310eaac (patch) | |
tree | 9a026d4edd3c840b49c2b2c79115d143285903f1 | |
parent | 4187ba40e77ee91ae99b6fb6356cced2eb717d7e (diff) | |
download | textadept-e672ee07c4b97fa205db0a5c75f69d9f8310eaac.tar.gz textadept-e672ee07c4b97fa205db0a5c75f69d9f8310eaac.zip |
Fixed bugs with tonumber(cocoa_dialog(...)) in various files.
Instead of the extra overhead when calling tonumber(), add the --no-newline
option and do a direct string comparison.
-rw-r--r-- | core/events.lua | 7 | ||||
-rw-r--r-- | core/file_io.lua | 7 | ||||
-rw-r--r-- | modules/textadept/editing.lua | 6 |
3 files changed, 11 insertions, 9 deletions
diff --git a/core/events.lua b/core/events.lua index 732b5d50..fffa5aca 100644 --- a/core/events.lua +++ b/core/events.lua @@ -372,11 +372,12 @@ add_handler('quit', end end if any then - if tonumber( cocoa_dialog( 'yesno-msgbox', { + if cocoa_dialog( 'yesno-msgbox', { title = 'Save?', text = 'Save changes before quitting?', - ['informative-text'] = list..'\nYou will have to save changes manually.' - } ) ) ~= 2 then return false end + ['informative-text'] = list..'\nYou will have to save changes manually.', + ['no-newline'] = true + } ) ~= '2' then return false end end textadept.io.save_session() return true diff --git a/core/file_io.lua b/core/file_io.lua index 5788c509..496afebd 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -137,11 +137,12 @@ end -- @usage buffer:close() function close(buffer) textadept.check_focused_buffer(buffer) - if buffer.dirty and tonumber( cocoa_dialog( 'yesno-msgbox', { + if buffer.dirty and cocoa_dialog( 'yesno-msgbox', { title = 'Save?', text = 'Save changes before closing?', - ['informative-text'] = 'You will have to save changes manually.' - } ) ) ~= 2 then return false end + ['informative-text'] = 'You will have to save changes manually.', + ['no-newline'] = true + } ) ~= '2' then return false end buffer:delete() return true end diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 1a06bae7..d032356d 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -223,9 +223,9 @@ function goto_line(line) title = 'Go To', text = 'Line Number:', ['no-newline'] = true - } ):match('%d+$') - if not line and line > -1 then return end - line = tonumber(line) + } ) + if line == '-1' then return end + line = tonumber( line:match('%d+$') ) end buffer:ensure_visible_enforce_policy(line - 1) buffer:goto_line(line - 1) |