Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lsp-lens-mode breaks end-of-visual-line #677

Closed
Khady opened this issue Mar 1, 2019 · 3 comments
Closed

lsp-lens-mode breaks end-of-visual-line #677

Khady opened this issue Mar 1, 2019 · 3 comments

Comments

@Khady
Copy link
Contributor

Khady commented Mar 1, 2019

Describe the bug

With lsp-lens-mode enabled, when at the start of a line that follows a lens, end-of-visual-line does nothing. The point is not moved at the end of the line. end-of-line doesn't have this issue.

To Reproduce

type demo =
  [ `Ok
  | `Error
  | `Exn of string
  ]

let f zzz xxx = zzz + xxx

let f zzz xxx = zzz + f xxx zzz

let f = Format.std_formatter

M-x lsp-lens-mode RET M-g c 59 RET M-: (end-of-visual-line) RET

image

Expected behavior

end-of-visual-line should have the usual behavior, point should be moved at the end of the line.

Which Language Server did you use

ocamlmerlin-lsp

OS

debian strech, emacs 27 from git

Error callstack

>>> ocamlmerlin-lsp:30391(async)
Content-Length: 199

{
  "jsonrpc": "2.0",
  "method": "textDocument/codeLens",
  "params": {
    "textDocument": {
      "uri": "file:///tmp/test.ml"
    }
  },
  "id": 566
}

<<<< ocamlmerlin-lsp:30391
{
  "id": 566,
  "jsonrpc": "2.0",
  "result": [
    {
      "range": {
        "start": {
          "line": 10,
          "character": 0
        },
        "end": {
          "line": 10,
          "character": 28
        }
      },
      "command": {
        "title": "Format.formatter",
        "command": ""
      }
    },
    {
      "range": {
        "start": {
          "line": 8,
          "character": 0
        },
        "end": {
          "line": 8,
          "character": 31
        }
      },
      "command": {
        "title": "int -> int -> int",
        "command": ""
      }
    },
    {
      "range": {
        "start": {
          "line": 6,
          "character": 0
        },
        "end": {
          "line": 6,
          "character": 25
        }
      },
      "command": {
        "title": "int -> int -> int",
        "command": ""
      }
    }
  ]
}
@yyoncho
Copy link
Member

yyoncho commented Mar 1, 2019

It does not work only if you place the cursor at first char of the line. Here it is minimal code to reproduce the issue:

  1. M-x eval-defun when placed on the opening bracket.
  2. M-x end-of-visual-line - FAIL.
(let ((ov (make-overlay (point-at-bol) (point-at-eol))))
  (overlay-put ov 'before-string "XXX\n"))

This behaviour is either a emacs bug or the expected behavour when there is overlay with before-string set which contains \n.

(CC @Eli-Zaretskii)

@Eli-Zaretskii
Copy link

Lisp programs that futz with overlay strings with embedded newlines and then move visually should be prepared to deal with potential trouble. In this case, when you are at the beginning of the line, are you before the before-string or after it? If before, then the visual line ends at the newline embedded in the overlay string, right?

I made a change on the master branch to handle this case, hope I didn't break anything else by doing that. In general, Lisp programs are well advised to stay away of such techniques.

Thanks.

Silex pushed a commit to Silex/emacs that referenced this issue Mar 2, 2019
* src/indent.c (Fvertical_motion): Get out of overlay strings
with embedded newlines even if moving within the same screen
line.  See emacs-lsp/lsp-mode#677
for more details.
Fix test for IT_CHARPOS being at the beginning of the
accessible portion of the buffer.
@yyoncho
Copy link
Member

yyoncho commented Mar 2, 2019

@Eli-Zaretskii

If before, then the visual line ends at the newline embedded in the overlay string, right?

I guess this was the problem.

Closing based on the previous comment.

@yyoncho yyoncho closed this as completed Mar 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants