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

sideline wrapping lines #29

Open
piranha opened this issue Nov 26, 2024 · 12 comments
Open

sideline wrapping lines #29

piranha opened this issue Nov 26, 2024 · 12 comments

Comments

@piranha
Copy link

piranha commented Nov 26, 2024

Hey, I think it may be some problem with my configuration, but sideline looks like that for me:

image

something causes it to wrap last char; is there a way to fix this?

@jcs090218
Copy link
Member

It should have been resolved long time ago. 🤔 Is this related to #18?

@piranha
Copy link
Author

piranha commented Nov 27, 2024

Uhh, so overflow-newline-into-fringe is t for me. If I print what's going on in sideline--align-right it looks like this:

[/p]: offset => 0
[/p]: (and graphic-p (> (nth 1 fringes) 0) (not overflow-newline-into-fringe)) => nil
[/p]: graphic-p => t
[/p]: (= 0 (nth 1 fringes)) => nil ;; right fringe is enabled

so offset is zero, first if returns 0, and second if also returns 0. So I don't get any additional offset and it wraps a single char on the next line. I guess something else is enabled that eats in the space? :(

@jcs090218
Copy link
Member

I recommend you try it in emacs -q (a clean environment). If everything seems to be working, then try minimizing your configuration. 🤔 Maybe there is a bug due to recent changes, or other plugins are conflicting with the sideline.

@eval-exec
Copy link

eval-exec commented Dec 19, 2024

Hello, I get this issue too. And I have a minimal reproduce init.el and reproduce it by emacs -Q -l reproduce.el:
image

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired.  See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)

(setq-default use-package-always-ensure t)



(use-package marginalia
  :hook
  (vertico-mode . marginalia-mode)
  )

(use-package vertico
  :config
  (vertico-mode)
  (setq vertico-grid-annotate 10)
  (setq vertico-multiform-commands
	'(
	   (execute-extended-command grid)
	   )
	)
  (vertico-multiform-mode))

(use-package flycheck
  ;; :bind
  ;; (:prefix "C-c !" :prefix-map flycheck-keymap-prefix)
  :custom
  (flycheck-disabled-checkers '(
								 rust
								 rust-cargo
								 lsp
								 python-flake8
								 python-pycompile
								 python-pyright
								 python-mypy
								 ;; rust-clippy
								 emac-lisp-checkdoc))
  (flycheck-set-indication-mode 'left-fringe)
  ;; :custom-face
  ;; (flycheck-info ((t (:underline ))))
  ;; (flycheck-warning ((t (:underline nil))))
  ;; (flycheck-error-list-highlight ((t (:background "midnight blue"))))
  :init
  (setq-default
	flycheck-display-errors-delay 0.1
	flycheck-mode-line-prefix "Fly"
	flycheck-display-errors-function nil ;;#'flycheck-display-error-messages-unless-error-list
	flycheck-idle-change-delay 0.5
	flycheck-idle-buffer-switch-delay 1.0
	flycheck-checker-error-threshold 100
	flycheck-rust-executable nil; "cargo-clippy"
	flycheck-rust-clippy-executable
	"cargo-clippy"
	;; "~/soft/matrix_wan_exec/cargo"
	flycheck-rust-args nil; '("--profile" "rust-analyzer")
	flycheck-relevant-error-other-file-show nil
	)
  (setq-default flycheck-enable-flycheck t)
  (defun exec/flycheck-mode()
	(when (buffer-local-value 'flycheck-enable-flycheck (current-buffer))
	  (flycheck-mode)))

  :hook
  (prog-mode . exec/flycheck-mode)

  :config

  (defun exec/flycheck-toggle-default()
	(interactive)
	(if flycheck-enable-flycheck
	  (setq-default flycheck-enable-flycheck nil)
	  (setq-default flycheck-enable-flycheck t)))

  ;; flycheck err cycle
  ;; Optional: ensure flycheck cycles, both when going backward and forward.
  ;; Tries to handle arguments correctly.
  ;; Since flycheck-previous-error is written in terms of flycheck-next-error,
  ;; advising the latter is enough.
  (defun flycheck-next-error-loop-advice (orig-fun &optional n reset)
										; (message "flycheck-next-error called with args %S %S" n reset)
	(condition-case err
	  (apply orig-fun (list n reset))
	  ((user-error)
		(let ((error-count (length flycheck-current-errors)))
		  (if (and
				(> error-count 0) ; There are errors so we can cycle.
				(equal
				  (error-message-string err) "No more Flycheck errors"))
			;; We need to cycle.
			(let*
			  ((req-n
				 (if (numberp n)
				   n
				   1)) ; Requested displacement.
										; An universal argument is taken as reset, so shouldn't fail.
				(curr-pos
				  (if (> req-n 0)
					(- error-count 1)
					0)) ; 0-indexed.
				(next-pos (mod (+ curr-pos req-n) error-count))) ; next-pos must be 1-indexed
										; (message "error-count %S; req-n %S; curr-pos %S; next-pos %S" error-count req-n curr-pos next-pos)
										; orig-fun is flycheck-next-error (but without advise)
										; Argument to flycheck-next-error must be 1-based.
			  (apply orig-fun (list (+ 1 next-pos) 'reset)))
			(signal (car err) (cdr err)))))))

  (advice-add
	'flycheck-next-error
	:around #'flycheck-next-error-loop-advice)


  ;; (add-to-list 'global-mode-string 'flycheck-mode-line)

  ;; (defun exec/header-line-hook()
  ;; 	(add-to-list 'header-line-format
  ;; 	  flycheck-mode-line t)
  ;; 	)
  ;; (add-hook 'breadcrumb-local-mode-hook 'exec/header-line-hook)
  (defun exec/flycheck-status-line()
	(format "%s"
	  (buffer-local-value
		'flycheck-last-status-change
		(current-buffer)
		)
	  )
	(concat
	  (propertize " Flycheck"
		'face '(:foreground "white" :background "tan4"))
	  (propertize
		(format (if (bound-and-true-p flycheck-mode)
				  (format "%s" flycheck-last-status-change) " off "))
		'face '(:foreground "white" :background "gray40")))
	)

  (add-to-list 'header-line-format '(:eval (exec/flycheck-status-line)) t)


  (use-package flycheck-posframe
	:disabled
	:hook (flycheck-mode . flycheck-posframe-mode)
	:custom-face
	(flycheck-posframe-face
	  ((t (:family "HarmonyOS Sans" :height 0.8 :inherit nil))))
	(flycheck-posframe-border-face
	  ((t (:inherit flycheck-posframe-face))))
	(flycheck-posframe-background-face
	  ((t (:inherit flycheck-posframe-face))))
	:config
	(setq-default
	  flycheck-posframe-position 'window-top-right-corner
	  flycheck-posframe-border-use-error-face t
	  flycheck-posframe-border-width 1
	  flycheck-posframe-info-prefix "💬 "
	  flycheck-posframe-warning-prefix "⚠️ "
	  flycheck-posframe-error-prefix ""))
  )





(use-package sideline
  :hook
  (after-init . global-sideline-mode)
  :init
  (setq sideline-backends-left-skip-current-line t ; don't display on current line (left)
    sideline-backends-right-skip-current-line t ; don't display on current line (right)
    sideline-order-left 'up                    ; or 'up
    sideline-order-right 'up                     ; or 'down
    sideline-format-left "%s"                 ; format for left aligment
    sideline-format-right "%s"                ; format for right aligment
    sideline-priority 10                        ; overlays' priority
    sideline-display-backend-name nil
	sideline-force-display-if-exceeds t
	sideline-backends-left nil
	sideline-backends-right '(sideline-flycheck)
	)

  :custom-face
  (sideline-flycheck-success ((t
								(
								  :family "JetBrainsMono Nerd Font"
								  :weight normal
								  :background "green"
								  :foreground "black"
								  :height 1.0
								  ))))
  (sideline-flycheck-warning ((t
								(
								  :family "JetBrainsMono Nerd Font"
								  :weight normal
								  :background "orange"
								  :foreground "black"
								  :height 1.0
								  ))))
  (sideline-flycheck-error ((t
							  (
								:family "JetBrainsMono Nerd Font"
								:weight normal
								:background "dark red"
								:foreground "yellow"
								:height 1.0
								))))


  )            ; display the backend name


(use-package sideline-flycheck
  :after sideline
  :hook
  (flycheck-mode . sideline-flycheck-setup)
  :init

  (setq
	sideline-flycheck-max-lines 100
	sideline-flycheck-show-checker-name nil
	sideline-flycheck-display-mode 'point
	)

  :config

  )

and the rust file: (put cursor in the empty line, below of the fn fib line , above of the end } line)

// snippet of code @ 2024-12-19 21:34:06

// === Rust Playground ===
// This snippet is in: ~/Projects/github.com/eval-exec/emacs-rust-playground/RP-2024-12-19-21_34_06/

// Execute the snippet: C-c C-c
// Delete the snippet completely: C-c k
// Toggle between main.rs and Cargo.toml: C-c b

fn main() {
    
    println!("Results:")
}

fn fib(n: usize) -> usize {

}

@eval-exec
Copy link

eval-exec commented Dec 19, 2024

Sorry, the reproduce config file is too long, but it can realy reporduce it by emacs -Q -l reproduce.el

@jcs090218
Copy link
Member

Hello, I get this issue too. And I have a minimal reproduce init.el and reproduce it by emacs -Q -l reproduce.el:

I think you have this issue due to (setq sideline-force-display-if-exceeds t). That's off by default. 🤔

@eval-exec
Copy link

Hello, I get this issue too. And I have a minimal reproduce init.el and reproduce it by emacs -Q -l reproduce.el:

I think you have this issue due to (setq sideline-force-display-if-exceeds t). That's off by default. 🤔

After I set it to nil, the issue still exist.

@eval-exec
Copy link

eval-exec commented Dec 20, 2024

,I thinks the issue is related to "the overlay in the tail of the {":

There are too flycheck's overlay: one after the {, another is above the }:
image

When I move cursor to the line above }:
the overlay behind { moved:

(It think sideline-mode put its overlay between the { and the "flycheck's overlay", cause line wrap)

image

@jcs090218
Copy link
Member

On my side, it pushes the overlay down to the next line but doesn't affect the sideline's display. 🤔

2024-12-19 17 33 59

@eval-exec
Copy link

Could you retry after shutdown the lsp server?

@jcs090218
Copy link
Member

Could you retry after shutdown the lsp server?

Nothing has changed. Same result. 🤔

@eval-exec
Copy link

I do trace-function to sideline--align-right
It seems that sideline printed a \n newline char on the right?

======================================================================
1 -> (sideline--align-right #("consider returning the local binding `n`: `\n    n\n`" 0 51 (face sideline-flycheck-success)) 0)
1 <- sideline--align-right: (660)

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