Comments (7)
Hi @sakhnik Have you found the solution for this problem?
I've made a patch which basically works
diff --git a/autoload/nvimgdb.vim b/autoload/nvimgdb.vim
index 71673f0..4fb1c66 100644
--- a/autoload/nvimgdb.vim
+++ b/autoload/nvimgdb.vim
@@ -99,3 +99,18 @@ function! nvimgdb#GlobalCleanup()
delcommand GdbLopenBacktrace
delcommand GdbLopenBreakpoints
endfunction
+
+function! nvimgdb#KeepCursor(winid) abort
+ let curr = win_getid()
+ noa keepalt call win_gotoid(a:winid)
+ let wininfo = getwininfo(a:winid)[0]
+ let botline = wininfo['botline']
+ let topline = wininfo['topline']
+ let currlnum = line('.')
+ let lastlnum = line('$')
+ if botline - topline > &scrolloff && botline - currlnum < &scrolloff && botline < lastlnum
+ let topline += &scrolloff - (botline - currlnum)
+ call winrestview({'topline': topline})
+ endif
+ noa keepalt call win_gotoid(curr)
+endfunction
diff --git a/rplugin/python3/gdb/win.py b/rplugin/python3/gdb/win.py
index 87d453c..a7ee547 100644
--- a/rplugin/python3/gdb/win.py
+++ b/rplugin/python3/gdb/win.py
@@ -84,7 +84,11 @@ class Win(Common):
# Ensure the jump window is available
with self._saved_mode():
self._ensure_jump_window()
- if not self.jump_win:
+ if self.jump_win:
+ winid = self.vim.call("bufwinid", target_buf)
+ if winid > 0:
+ self.vim.call('nvimgdb#KeepCursor', winid)
+ else:
raise AssertionError("No jump window")
# The terminal buffer may contain the name of the source file
from nvim-gdb.
That's a good idea. You could set the option scrolloff
to a positive number to keep the cursor off the edges. Consider using setlocal scrolloff=5
to make the change local to the window.
Could you please prepare a pull request?
from nvim-gdb.
#38 Please check the pr, tks.
from nvim-gdb.
The problem still exists for me. Can anyone please reproduce it?
from nvim-gdb.
Thanks for the report! I think I understand the issue. The option 'scrolloff' only handles the cursor. So we just need to let the cursor follow the current line sign.
UPD: The code is actually there:
nvim-gdb/rplugin/python3/gdb/win.py
Line 106 in 531a575
from nvim-gdb.
The scrolloff
is set only the first time the code window is opened(BufEnter event is fired and the code related to set scrolloff
is executed). After that the cursor won't enter the code window again, correspondingly the BufEnter event won't be fired.
from nvim-gdb.
That's a good solution, I like it. Could you please prepare a pull request?
I'd like to run it through the test suite, then we can accept it as is.
But there's a bigger change coming in the branch lua
(fa1e3d9). I'll take your change into it.
from nvim-gdb.
Related Issues (20)
- Is it possible to disable default keybindings? HOT 1
- Implement checkhealth
- Feature Request: Make vim the owner of breakpoints and not the debugger HOT 3
- Error detected while processing TabLeave Autocommands for "*" on tabnew: GdbStartPDB HOT 7
- [Solved] Unknown sign: GdbBreakpoint0 after merging d7504a52e3f5f1b6d7f62a006646681bde65a310 HOT 2
- 'GdbStart...' error if delete buffer at event 'NvimGdbCleanup' HOT 2
- mingw support? HOT 6
- Port the test suite to be based on Lua
- Port launch scripts to Lua
- Port PTY proxy to Lua
- Support PerlDB HOT 4
- gdb attach mode HOT 1
- My environment breaks the plugin HOT 2
- error calling thread_get_state for gp registers for thread 0x1d3 HOT 9
- nvim_config_override works with vimscript functions but not lua functions HOT 1
- DWARF2 Queue Guard Internal Error on run HOT 6
- showing variables when debugging with bashdb HOT 3
- [Question] unable to run lldb on Mac HOT 2
- GDB crashes with Fatal signal: Segmentation fault
- "Break" in command line history pdb HOT 1
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 nvim-gdb.