Coder Social home page Coder Social logo

Main Column Line Numbers Only about lf HOT 8 CLOSED

jbytes1027 avatar jbytes1027 commented on August 24, 2024
Main Column Line Numbers Only

from lf.

Comments (8)

joelim-work avatar joelim-work commented on August 24, 2024 1

I have just merged the change, I think it's the only way we can get any sort of feedback. Let's wait and see what happens.

from lf.

joelim-work avatar joelim-work commented on August 24, 2024

Line numbers was requested in #130 and implemented in #133. I couldn't find any mention in the discussions about limiting the display to the main window, so I guess it was never considered at all.

Actually this isn't hard to achieve, it should just be a one line change:

diff --git a/ui.go b/ui.go
index f7684ec..7b9d3cb 100644
--- a/ui.go
+++ b/ui.go
@@ -385,21 +385,21 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
 
 	beg := max(dir.ind-dir.pos, 0)
 	end := min(beg+win.h, len(dir.files))
 
 	if beg > end {
 		return
 	}
 
 	var lnwidth int
 
-	if gOpts.number || gOpts.relativenumber {
+	if (gOpts.number || gOpts.relativenumber) && dirStyle.role == Active {
 		lnwidth = 1
 		if gOpts.number && gOpts.relativenumber {
 			lnwidth++
 		}
 		for j := 10; j <= len(dir.files); j *= 10 {
 			lnwidth++
 		}
 	}
 
 	for i, f := range dir.files[beg:end] {

The main problem is deciding on how this can be configured by users. Which one of the following do you prefer?

Solution Description
Change number/relativenumber to display line numbers on the main window only This is a breaking change, and some users may not like this. However since I don't really use this feature much, I don't know which one is more preferred and I am probably indifferent about this anyway.
Change number from a boolean option to a string (e.g. all/active/off) This may end up being slightly unintuitive because the corresponding option in Vim is boolean. It is also a breaking change since users who have set number true will have the change it to set number all to maintain the existing behavior.
Add another boolean option to control whether line numbers are displayed on all windows or the main window only This won't result in a breaking change, but would introduce another option and there are a lot of them already.

I'm leaning somewhere between the first and third options. Perhaps it's worth leaving this issue open so others can provide their opinions, but in the meantime you can use the above patch if you're willing to build from source.

from lf.

jbytes1027 avatar jbytes1027 commented on August 24, 2024

Thanks for the patch and detailed response.

My vote would be option 1. I don't understand the need for line numbers in columns 1 or 3. Maybe for visual consistency? Option 3 works but feels oddly hyper specific of an option.

from lf.

joelim-work avatar joelim-work commented on August 24, 2024

After thinking about this a bit more, I sort of want to avoid adding too many new options (especially for something small like this) since lf has a lot of options already. The problem with UI configuration in general is that every user has their own preference for how things should be displayed and it's practically impossible to satisfy everyone 100% without adding a heap of options.

I think what we can do is go with the first option, and then revisit this if there are users out there who want line numbers for every window.

For reference, I tried joshuto (set the line_number_style option) and it also displays line numbers on the main window only.

from lf.

joelim-work avatar joelim-work commented on August 24, 2024

I've submitted a PR for this #1752

from lf.

jbytes1027 avatar jbytes1027 commented on August 24, 2024

Fixed via PR #1752

from lf.

joelim-work avatar joelim-work commented on August 24, 2024

So just an update on this, the PR #1752 was closed because I deleted my fork to test something unrelated.

Although I rarely use line numbers myself, I have so far been reluctant to make any breaking changes without providing a way to keep the original behavior. Especially for anything relating to the UI display, which tends to be very subjective and based on user preferences. I am still a bit concerned that making this kind of change will just lead to someone else raising an issue to request it being reverted.

At the same time I am not sure whether it is a good idea to add more configuration options for minor things like this. I looked over the documentation just now and found that there are already a large number of options purely for configuring the display:

  • borderfmt
  • copyfmt
  • cursoractivefmt
  • cursorparentfmt
  • cursorpreviewfmt
  • cutfmt
  • drawbox
  • errorfmt
  • icons
  • info
  • infotimefmtnew
  • infotimefmtold
  • numberfmt
  • preview
  • promptfmt
  • ratios
  • roundbox
  • rulerfmt
  • selectfmt
  • statfmt
  • tagfmt
  • timefmt
  • truncatechar
  • truncatepct

At some point it becomes overwhelming for both users and maintainers. Going off on a tangent, I can see a possibility that someone in future will request the ability to separately color different types of line numbers (i.e. CursorLineNr, LineNrAbove and LineNrBelow in Vim).


Anyway to address this particular issue, since multiple users have now requested this, I think it is probably better to proceed with this change. However if there is negative feedback from other users, then I will have to revert it until there is a better solution.

from lf.

masroof-maindak avatar masroof-maindak commented on August 24, 2024

I for one discovered this option by complete accident while going through the manpage, and my first thought was wanting the numbers in only the central column - partially because the others are fairly useless, and partially for the visual clutter.

Of course, if, as you suggested, some negative feedback does arise, then we could revert and reconsider our approach.

from lf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.