Comments (7)
from textadept.
Say you have 2 files open:
- init.lua
- session
You go to the first opened init.lua
, then you open a new buffer and close the new buffer:
What happens is:
Saving view state session
Switch to init.lua
Restoring init.lua
Switch to init.lua
Restoring init.lua
So if you change wrap mode oder margins in the new buffer (like i do in Textredux) the session
file passed by while closing inherits the view state from the new buffer.
The problem seems to be that there is no "after_switch" event fired for the passing-by of the last buffer in _BUFFERS
.
from textadept.
from textadept.
Thanks!
Maybe disconnecting events before the switch to the previous buffer could be a fix.
-- Keeps track of, and switches back to the previous buffer after buffer close.
events.connect(
events.BUFFER_BEFORE_SWITCH, function() view._prev_buffer = buffer end)
events.connect(events.BUFFER_DELETED, function()
if _BUFFERS[view._prev_buffer] and buffer ~= view._prev_buffer then
events.disconnect(events.VIEW_BEFORE_SWITCH, save_view_state)
events.disconnect(events.BUFFER_BEFORE_SWITCH, save_buffer_state)
view:goto_buffer(view._prev_buffer)
events.connect(events.BUFFER_BEFORE_SWITCH, save_view_state)
events.connect(events.VIEW_BEFORE_SWITCH, save_view_state)
end
end)
Seems to fix the example scenario above, will check further. Maybe not both need to be disconnected. [Edited to use correct event]
from textadept.
The above would likely work with save_view_state
only.
Thus, the following also seems to do the trick:
-- Keeps track of, and switches back to the previous buffer after buffer close.
events.connect(
events.BUFFER_BEFORE_SWITCH, function() view._prev_buffer = buffer end)
events.connect(events.BUFFER_DELETED, function()
if _BUFFERS[view._prev_buffer] and buffer ~= view._prev_buffer then
restore_view_state()
view:goto_buffer(view._prev_buffer)
end
end)
from textadept.
from textadept.
Awesome, thank you!
Next time i'll try to submit a reproducible test case, this is nice :-)
from textadept.
Related Issues (20)
- Crash of Textadept while toggling wrapping with Ctrl+\ HOT 5
- textadept doesn't read from stdin HOT 9
- Unpredictable behavior of statusbar and view while using `ui.buffer_statusbar_text="..."` HOT 7
- Error when compiling for ARM HOT 4
- Each consecutive invocation from the CLI spawns a new process HOT 1
- `view.element_color[view.ELEMENT_CARET]` and `ui.find.entry_font` in `~/.textadept/init.lua` have no effect HOT 2
- Editor View shows extraneous vertical lines next to a number of character boundaries at 150% scaling HOT 4
- Horizontal scrolling in textadept-curses HOT 2
- Different toggle comment behaviour HOT 6
- Error when saving in a Windows path localised region HOT 8
- Add iconv library for FreeBSD HOT 1
- Segfault on FreeBSD HOT 1
- 建议textadept增加简体中文 HOT 1
- Multiple cursors disappear on undo & redo HOT 7
- ui.dialogs.input too small and not resizable HOT 1
- Tabs Management HOT 1
- buffer:set_encoding('UTF-8') causes marking buffer as changed HOT 5
- Compilation on Ubuntu 18.04 failed when trying to build scintilla HOT 3
- Making syntax highlighting in Textadept providing features supported in SciTE Python lexer HOT 7
- Alternative download site for current Textadept files HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from textadept.