aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2021-04-14 22:46:20 -0400
committerGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2021-04-14 22:46:20 -0400
commita1843428319d1f96acaaf42e81e701de9988d06f (patch)
tree220e91d1110f1856523c50df6c7e4752312a0d54 /modules
parent07f1785afd1afc28d18a49999ea6f3b3dc836926 (diff)
Attempt to restore view scroll state after `textadept.editing.filter_through()`.
Also prefer `view.first_visible_line =` rather than `view:scroll_lines()` since the latter is only needed when display lines are involved.
Diffstat (limited to 'modules')
-rw-r--r--modules/textadept/editing.lua3
-rw-r--r--modules/textadept/find.lua2
-rw-r--r--modules/textadept/session.lua2
3 files changed, 4 insertions, 3 deletions
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua
index ae98720e..540c5aec 100644
--- a/modules/textadept/editing.lua
+++ b/modules/textadept/editing.lua
@@ -596,7 +596,7 @@ end
function M.filter_through(command)
assert(not (WIN32 and CURSES), 'not implemented in this environment')
assert_type(command, 'string', 1)
- local s, e = buffer.selection_start, buffer.selection_end
+ local s, e, top_line = buffer.selection_start, buffer.selection_end, view.first_visible_line
if s == e then
-- Use the whole buffer as input.
buffer:target_whole_document()
@@ -629,6 +629,7 @@ function M.filter_through(command)
end
end
buffer:replace_target(output:iconv('UTF-8', _CHARSET))
+ view.first_visible_line = top_line
if s == e then
buffer:goto_pos(s)
return
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index 0d90885f..df51048b 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -223,7 +223,7 @@ local function find(text, next, flags, no_wrap, wrapped)
pos = find(text, next, flags, true, true)
if pos == -1 then
ui.statusbar_text = _L['No results found']
- view:line_scroll(0, first_visible_line - view.first_visible_line)
+ view.first_visible_line = first_visible_line
buffer:goto_pos(incremental_orig_pos or anchor)
end
end
diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua
index bf19e78e..b36b158e 100644
--- a/modules/textadept/session.lua
+++ b/modules/textadept/session.lua
@@ -63,7 +63,7 @@ function M.load(filename)
if lfs.attributes(buf.filename) then
io.open_file(buf.filename)
buffer:set_sel(buf.anchor, buf.current_pos)
- view:line_scroll(0, buf.top_line - view.first_visible_line)
+ view.first_visible_line = buf.top_line
for _, line in ipairs(buf.bookmarks) do
buffer:marker_add(line, textadept.bookmarks.MARK_BOOKMARK)
end