Repository navigation
Fix first commit-buffer key lookup and small-font newline geometry #703
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
Merged
eval-exec
merged 3 commits into
eval-exec:main
from
ponchoalv:fix/macos-commit-input-and-vc-display
Nov 7, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| ;;; commit-editing.el --- Commit-buffer input and separator regressions -*- lexical-binding: t; -*- | ||
|
|
||
| (defvar neo-commit-old-map-count 0) | ||
| (defconst neo-commit-async-probe | ||
| (member (getenv "NEOMACS_COMMIT_PROBE") '("async-map" "async-map-delayed")) | ||
| "Non-nil when this fixture checks asynchronous command dispatch.") | ||
| (defconst neo-commit-overlay-probe | ||
| (equal (getenv "NEOMACS_COMMIT_PROBE") "overlay-separator") | ||
| "Non-nil when the small newline belongs to an overlay string.") | ||
|
|
||
| (defun neo-commit-probe-finish () | ||
| "Check the completed input sequence or the redisplayed separator geometry." | ||
| (interactive) | ||
| (condition-case err | ||
| (progn | ||
| (if neo-commit-async-probe | ||
| (progn | ||
| (unless (= neo-commit-old-map-count 0) | ||
| (error "First commit key used the previous buffer's map")) | ||
| (unless (equal (with-current-buffer "*commit-message*" (buffer-string)) "aa") | ||
| (error "Commit buffer did not receive both characters"))) | ||
| (redisplay t) | ||
| (let* ((summary-y (cdr (posn-x-y (posn-at-point 1)))) | ||
| (separator-y (cdr (posn-x-y (posn-at-point 11)))) | ||
| (body-y (cdr (posn-x-y (posn-at-point 12)))) | ||
| (normal-height | ||
| (if neo-commit-overlay-probe | ||
| (- (cdr (posn-x-y (posn-at-point 17))) body-y) | ||
| (- separator-y summary-y))) | ||
| (separator-height | ||
| (if neo-commit-overlay-probe | ||
| (- body-y summary-y (* 2 normal-height)) | ||
| (- body-y separator-y)))) | ||
| (unless (and (> separator-height 0) | ||
| (< separator-height (/ normal-height 2.0))) | ||
| (error "Separator is not short: normal=%S separator=%S" | ||
| normal-height separator-height)))) | ||
| (princ "COMMIT-EDITING-PASS\n" 'external-debugging-output) | ||
| (kill-emacs 0)) | ||
| (error | ||
| (princ (format "COMMIT-EDITING-FAIL %S\n" err) 'external-debugging-output) | ||
| (kill-emacs 1)))) | ||
|
|
||
| ;; Install the watchdog before setup can enter any input wait. | ||
| (run-at-time 10 nil | ||
| (lambda () | ||
| (princ "COMMIT-EDITING-FAIL watchdog expired\n" 'external-debugging-output) | ||
| (kill-emacs 1))) | ||
|
|
||
| (if neo-commit-async-probe | ||
| (progn | ||
| ;; This sentinel is dispatched only after both queued characters, even | ||
| ;; when slow startup makes multiple timers due in one service pass. | ||
| (global-set-key [neo-commit-probe-finish] #'neo-commit-probe-finish) | ||
| (switch-to-buffer (get-buffer-create "*commit-status*")) | ||
| (use-local-map (make-sparse-keymap)) | ||
| (local-set-key "a" (lambda () (interactive) | ||
| (setq neo-commit-old-map-count (1+ neo-commit-old-map-count)))) | ||
| (with-current-buffer (get-buffer-create "*commit-message*") | ||
| (fundamental-mode)) | ||
| ;; Like a with-editor process filter: display the new buffer, but | ||
| ;; restore the old current buffer while the command loop awaits input. | ||
| (run-at-time 0.5 nil | ||
| (lambda () | ||
| (save-current-buffer (switch-to-buffer "*commit-message*")) | ||
| (setq unread-command-events | ||
| (list ?a ?a 'neo-commit-probe-finish))))) | ||
| (require 'log-edit) | ||
| (switch-to-buffer (get-buffer-create "*commit-separator*")) | ||
| (if neo-commit-overlay-probe | ||
| (progn | ||
| (fundamental-mode) | ||
| (insert "Summary: \n\nbody\nnext\n") | ||
| (overlay-put (make-overlay 11 11) 'before-string | ||
| (propertize "\n" 'face | ||
| '(:height 0.1 :inverse-video t :extend t)))) | ||
| ;; Checkout-local settings must not prompt during an isolated GUI probe. | ||
| (let ((enable-dir-local-variables nil)) | ||
| (log-edit-mode)) | ||
| (insert "Summary: \n\nbody\n") | ||
| (font-lock-ensure)) | ||
| (goto-char 10)) | ||
|
|
||
| (unless neo-commit-async-probe | ||
| (run-at-time 2 nil #'neo-commit-probe-finish)) | ||
|
|
||
| ;; Reproduce startup slow enough to expire both timers in the old fixture, | ||
| ;; before the command loop could dispatch either queued character. | ||
| (when (equal (getenv "NEOMACS_COMMIT_PROBE") "async-map-delayed") | ||
| (let ((deadline (+ (float-time) 3))) | ||
| (while (< (float-time) deadline)))) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| //! Real command-input and small-font newline regressions, including macOS. | ||
| #![cfg(any(target_os = "linux", target_os = "macos"))] | ||
|
|
||
| use neomacs_gui_tests::{ | ||
| DisplayHarness, GuiBackend, GuiRunOptions, GuiScenario, GuiTestPlan, ProcessGuiCommandRunner, | ||
| }; | ||
| use std::{fs, path::PathBuf, time::Duration}; | ||
|
|
||
| /// Honor explicit compositor selection, defaulting to the host's native backend. | ||
| fn commit_probe_backend(configured: Option<&str>) -> GuiBackend { | ||
| match configured { | ||
| Some("wayland" | "linux-wayland") => GuiBackend::LinuxWayland, | ||
| Some("x11" | "linux-x11") => GuiBackend::LinuxX11, | ||
| Some("macos") => GuiBackend::Macos, | ||
| None if cfg!(target_os = "macos") => GuiBackend::Macos, | ||
| None => GuiBackend::LinuxX11, | ||
| Some(other) => panic!("unsupported NEOMACS_GUI_TEST_BACKEND={other:?}"), | ||
| } | ||
| } | ||
|
|
||
| /// Run a native commit-editing fixture and require its explicit success marker. | ||
| fn run_commit_probe(probe: &str) { | ||
| let root = neomacs_infra::crate_root!().join("../.."); | ||
| let configured = std::env::var("NEOMACS_GUI_TEST_BACKEND").ok(); | ||
| let backend = commit_probe_backend(configured.as_deref()); | ||
| let artifacts = root | ||
| .join("target/neomacs-gui-tests") | ||
| .join(format!("commit-{probe}")); | ||
| let session = DisplayHarness::for_backend(backend) | ||
| .start_session(&artifacts) | ||
| .unwrap(); | ||
| let program = std::env::var_os("NEOMACS_GUI_TEST_BINARY") | ||
| .map(PathBuf::from) | ||
| .unwrap_or_else(|| root.join("target/release/neomacs")); | ||
| let mut plan = GuiTestPlan::new( | ||
| backend, | ||
| &root, | ||
| &artifacts, | ||
| GuiScenario::new( | ||
| probe, | ||
| root.join("crates/neomacs-gui-tests/fixtures/commit-editing.el"), | ||
| ), | ||
| ) | ||
| .with_program(program) | ||
| .with_env("NEOMACS_COMMIT_PROBE", probe) | ||
| .with_env("RUST_LOG", "warn"); | ||
| for (key, value) in session.env() { | ||
| plan = plan.with_env(key, value); | ||
| } | ||
| let result = plan | ||
| .run_with( | ||
| &mut ProcessGuiCommandRunner, | ||
| GuiRunOptions::with_timeout(Duration::from_secs(20)), | ||
| ) | ||
| .unwrap(); | ||
| let stderr = fs::read_to_string(&result.artifacts.stderr).unwrap_or_default(); | ||
| assert!(!result.timed_out, "{result:#?}\n{stderr}"); | ||
| assert_eq!(result.exit_code, Some(0), "{result:#?}\n{stderr}"); | ||
| assert!(stderr.contains("COMMIT-EDITING-PASS"), "{stderr}"); | ||
| } | ||
|
|
||
| /// Backend aliases and platform defaults must not require a live compositor. | ||
| #[test] | ||
| fn commit_probe_respects_requested_backend() { | ||
| for name in ["wayland", "linux-wayland"] { | ||
| assert_eq!(commit_probe_backend(Some(name)), GuiBackend::LinuxWayland); | ||
| } | ||
| for name in ["x11", "linux-x11"] { | ||
| assert_eq!(commit_probe_backend(Some(name)), GuiBackend::LinuxX11); | ||
| } | ||
| assert_eq!(commit_probe_backend(Some("macos")), GuiBackend::Macos); | ||
| assert_eq!( | ||
| commit_probe_backend(None), | ||
| if cfg!(target_os = "macos") { | ||
| GuiBackend::Macos | ||
| } else { | ||
| GuiBackend::LinuxX11 | ||
| } | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| #[should_panic(expected = "unsupported NEOMACS_GUI_TEST_BACKEND")] | ||
| fn commit_probe_rejects_unknown_backend() { | ||
| commit_probe_backend(Some("unknown")); | ||
| } | ||
|
|
||
| #[test] | ||
| fn first_commit_character_uses_the_asynchronously_selected_buffer() { | ||
| run_commit_probe("async-map"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn delayed_timer_service_waits_for_commit_commands() { | ||
| run_commit_probe("async-map-delayed"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn overlay_separator_uses_its_small_font_height() { | ||
| run_commit_probe("overlay-separator"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn log_edit_separator_uses_its_small_font_height() { | ||
| run_commit_probe("separator"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.