diff options
author | mitchell <70453897+orbitalquark@users.noreply.github.com> | 2020-10-20 15:29:03 -0400 |
---|---|---|
committer | mitchell <70453897+orbitalquark@users.noreply.github.com> | 2020-10-20 15:29:03 -0400 |
commit | 03c4016d07477781aa3adcc9edf340c0bec9c6c8 (patch) | |
tree | d3be089e9020807326a4e56562876ecb7bcf7892 /core/init.lua | |
parent | b682fbd4a6e53185e2556686079532ad0e42be94 (diff) |
Code cleanup.
Of note:
* io.save_all_files() does not visit each buffer to save anymore. An unintended
side-effect was checking for outside modification (but only if the file itself
was modified), so outside changes will always be saved over now.
* The menu clicked handler uses assert_type(), so the 'Unknown command'
localization is no longer needed.
* When printing to a new buffer type would split the view, use an existing split
view when possible.
* Prefer 'goto continue' construct in loops over nested 'if's.
* Fixed clearing of ui.find.replace_entry_text on reset in the GUI version.
* Fixed lack of statusbar updating when setting options like buffer EOL mode,
indentation, and encoding.
* Renamed internal new_snippet() to new() and put it in the snippet metatable.
Diffstat (limited to 'core/init.lua')
-rw-r--r-- | core/init.lua | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/core/init.lua b/core/init.lua index f71cd6be..e2674e48 100644 --- a/core/init.lua +++ b/core/init.lua @@ -44,22 +44,20 @@ end -- argument. -- Documentation is in core/.buffer.luadoc. local function text_range(buffer, start_pos, end_pos) - assert_type(start_pos, 'number', 2) - assert_type(end_pos, 'number', 3) local target_start, target_end = buffer.target_start, buffer.target_end - if start_pos < 1 then start_pos = 1 end - if end_pos > buffer.length + 1 then end_pos = buffer.length + 1 end - buffer:set_target_range(start_pos, end_pos) + buffer:set_target_range( + math.max(1, assert_type(start_pos, 'number', 2)), + math.min(assert_type(end_pos, 'number', 3), buffer.length + 1)) local text = buffer.target_text buffer:set_target_range(target_start, target_end) -- restore return text end +local GETNAMEDSTYLE = _SCINTILLA.properties.named_styles[1] -- Documentation is in core/.buffer.luadoc. local function style_of_name(buffer, style_name) - assert_type(style_name, 'string', 2) - local GETNAMEDSTYLE = _SCINTILLA.properties.named_styles[1] - return buffer:private_lexer_call(GETNAMEDSTYLE, style_name) + return buffer:private_lexer_call( + GETNAMEDSTYLE, assert_type(style_name, 'string', 2)) end events.connect(events.BUFFER_NEW, function() |