Skip to content

fix: fix out of bound error for citre-bounds-of-sym-or-op-at-point.#191

Merged
AmaiKinono merged 1 commit intouniversal-ctags:masterfrom
milanglacier:patch-2
Oct 15, 2025
Merged

fix: fix out of bound error for citre-bounds-of-sym-or-op-at-point.#191
AmaiKinono merged 1 commit intouniversal-ctags:masterfrom
milanglacier:patch-2

Conversation

@milanglacier
Copy link
Copy Markdown
Contributor

@milanglacier milanglacier commented Sep 24, 2025

When the point is put at the end of buffer, and the buffer content looks like this

df.|

where | is the cursor position,

the citre-bounds-of-sym-or-op-at-point will return the buffer position out of bound.

This commit fixes the above issue.

milanglacier added a commit to milanglacier/dotemacs that referenced this pull request Sep 24, 2025
…ng `citre-bounds-of-sym-or-op-at-point'

Override the `citre-bounds-of-sym-or-op-at-point'. The reason is that:
1. Fix the out of bound error addressed in universal-ctags/citre#191.

2. We don't really need to check whether the point is an operator, and
the frequent `save-excursion' in `citre-bounds-of-sym-or-op-at-point'
will impact the auto-completion performance.
@rongzhao-ambit
Copy link
Copy Markdown

I second this pull request and want this error to be fixed promptly.

When using citre-completion-at-point with a completion UI such as Company or Corfu, it is common to be editing text at the very end of the buffer. This scenario frequently triggers the following args-out-of-range error, indicating the OOB bug:

Debugger entered--Lisp error: (args-out-of-range #<buffer xxx> 4004 4003)
  citre-tags-get-symbol-at-point()
  citre-tags-get-symbol-default()
  citre-tags-get-symbol()
  citre-tags-get-completions-at-point()
  apply(citre-tags-get-completions-at-point nil)

@AmaiKinono
Copy link
Copy Markdown
Member

Thanks for the fix! However, I believe this is because a logical error in the original code.

skip-syntax-backward returns a non-positive number, so we should do this instead:

diff --git a/citre-common-util.el b/citre-common-util.el
index 795e9cf..555b81d 100644
--- a/citre-common-util.el
+++ b/citre-common-util.el
@@ -179,7 +179,7 @@ goes.  CASE-FOLD decides case-sensitivity."
       (let ((step-forward (save-excursion (skip-syntax-forward ".")))
             (step-backward (save-excursion (skip-syntax-backward "."))))
         (unless (and (eq 0 step-forward) (eq 0 step-backward))
-          (cons (- (point) step-backward)
+          (cons (+ (point) step-backward)
                 (+ (point) step-forward))))))

In your example:

df.|

The fixed version returns (3 . 4), which is in the bounds of buffer.

@milanglacier
Copy link
Copy Markdown
Contributor Author

Thanks for looking into this! I have updated the patch accordingly.

@AmaiKinono AmaiKinono merged commit 300596a into universal-ctags:master Oct 15, 2025
10 checks passed
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

Successfully merging this pull request may close these issues.

3 participants