emacs-lsp / lsp-origami

lsp-mode :heart: origami.el
GNU General Public License v3.0
43 stars 6 forks source link

Strange behavior #4

Closed Nathoufresh closed 4 years ago

Nathoufresh commented 4 years ago

I recently installed origami.el and noticed it does not fold functions in python.So I installed lsp-origami. When I'm in a python buffer with pyls connected I type M-x origami-mode then M-x lsp-origami-mode. If I try something like origami-toggle-node it shows

origami-fold-node: Tried to construct a node where the children overlap or are not distinct regions: ([232 5323 0 t nil #<overlay from 232 to 5323 in new.py>] [5353 5982 0 t nil #<overlay from 5353 to 5982 in new.py>] [5629 5803 0 t nil #<overlay from 5629 to 5803 in new.py>] [5661 5803 0 t nil #<overlay from 5661 to 5803 in new.py>] [5865 5890 0 t nil #<overlay from 5865 to 5890 in new.py>] [5958 5982 0 t nil #<overlay from 5958 to 5982 in new.py>] [6059 6090 0 t nil #<overlay from 6059 to 6090 in new.py>] [6150 6823 0 t nil #<overlay from 6150 to 6823 in new.py>] [6235 6705 0 t nil #<overlay from 6235 to 6705 in new.py>] [6607 6641 0 t nil #<overlay from 6607 to 6641 in new.py>] [6796 6823 0 t nil #<overlay from 6796 to 6823 in new.py>] [6880 7137 0 t nil #<overlay from 6880 to 7137 in new.py>] [6986 7019 0 t nil #<overlay from 6986 to 7019 in new.py>] [7165 7561 0 t nil #<overlay from 7165 to 7561 in new.py>] [7246 7467 0 t nil #<overlay from 7246 to 7467 in new.py>] [7345 7467 0 t nil #<overlay from 7345 to 7467 in new.py>] [7604 8082 0 t nil #<overlay from 7604 to 8082 in new.py>] [8156 8494 0 t nil #<overlay from 8156 to 8494 in new.py>] [8677 8842 0 t nil #<overlay from 8677 to 8842 in new.py>])

So not working, but if I disable lsp-origami then origami works well with functions. Strange behavior

kurnevsky commented 4 years ago

Got the same with metals server:

object Main {
  // aaa
  // aaa
  def main(args: Array[String]): Unit = {

    // aaa
    // aaa
  }
}
[Trace - 06:41:45 PM] Received response 'textDocument/foldingRange - (1817)' in 1ms.
Result: [
  {
    "kind": "comment",
    "endCharacter": 8,
    "startCharacter": 2,
    "endLine": 4,
    "startLine": 3
  },
  {
    "kind": "comment",
    "endCharacter": 10,
    "startCharacter": 4,
    "endLine": 8,
    "startLine": 7
  },
  {
    "kind": "region",
    "endCharacter": 1,
    "startCharacter": 12,
    "endLine": 10,
    "startLine": 2
  },
  {
    "kind": "region",
    "endCharacter": 3,
    "startCharacter": 40,
    "endLine": 9,
    "startLine": 5
  }
]

lsp--get-nested-folding-ranges gets:

(
  #s(lsp--folding-range 58 189 "region" (
    #s(lsp--folding-range 62 77 "comment" nil #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("startLine" 3 "endLine" 4 "startCharacter" 2 "endCharacter" 8 "kind" "comment")))
    #s(lsp--folding-range 118 187 "region" nil #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("startLine" 5 "endLine" 9 "startCharacter" 40 "endCharacter" 3 "kind" "region")))
    #s(lsp--folding-range 166 183 "comment" nil #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("startLine" 7 "endLine" 8 "startCharacter" 4 "endCharacter" 10 "kind" "comment")))
  )
  #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("startLine" 2 "endLine" 10 "startCharacter" 12 "endCharacter" 1 "kind" "region")))
)