XVimProject / XVim2

Vim key-bindings for Xcode 9
MIT License
2.31k stars 182 forks source link

Relative line numbers #343

Closed kentrh closed 3 years ago

kentrh commented 3 years ago

An effort to solve #28.

It is not a perfect solution, but it works better than not having any relative numbers in my opinion.

pebble8888 commented 3 years ago

@kentrh Thank you for your PR. It has been merged to develop branch.

rudedogg commented 3 years ago

It would have been better to extract the line number from the existing line number layer, but I couldn't find a way to do this, so instead I calculate the line numbers based on the existing layers' Y coordinate and padding between the layers. This may cause the relative numbers sometimes to be off, but it works most of the time.

I wonder if it would be possible to cast lineNumbersHostingLayer from CALayer -> CATextLayer and get the line number through the .string property?

Apologies for not trying it myself. Hoping this could help with #344.

kentrh commented 3 years ago

It would have been better to extract the line number from the existing line number layer, but I couldn't find a way to do this, so instead I calculate the line numbers based on the existing layers' Y coordinate and padding between the layers. This may cause the relative numbers sometimes to be off, but it works most of the time.

I wonder if it would be possible to cast lineNumbersHostingLayer from CALayer -> CATextLayer and get the line number through the .string property?

Apologies for not trying it myself. Hoping this could help with #344.

Hi, yeah, I tried that, but it didn't work. The funniest thing, though, was that I got that to work one time while I was debugging and stepping through, but I only got it working once, and I could not reproduce it, so I gave up after a while.