emacs-lsp / lsp-ui

UI integrations for lsp-mode
https://emacs-lsp.github.io/lsp-ui
GNU General Public License v3.0
1.04k stars 141 forks source link

lsp-ui-peek-find-definitions and split window #457

Open nloyola opened 4 years ago

nloyola commented 4 years ago

When I have the same buffer in side by side windows (C-x 3), the other buffer's start position is changed after calling lsp-ui-peek-find-definitions. For example, if my file is 80 lines long and in buffer A I have the point at line 75, and in buffer B I have the point at line 5 and I invoke lsp-ui-peek-find-definitions in buffer B, buffer A's start position is now line 72.

I traced through the code and found out that in lsp-ui-peek--peek-hide there is a call to set-window-start:

(set-window-start (get-buffer-window) lsp-ui-peek--win-start))

This causes the buffer's start position to be changed.

I would find it better if the position in buffer A was never changed.

Thanks

nloyola commented 4 years ago

I tried using frame-selected-window instead of get-buffer-window as follows:

(set-window-start (frame-selected-window) lsp-ui-peek--win-start))

and it does not have the problem.