Comments (5)
Workaround: use https://github.com/lewang/ws-butler
I will try to fix it later.
from copilot.el.
My apologies, I somehow missed that case (despite the comment talking exactly about that).
Seems that error happens because (thing-at-point 'line)
returns incorrect data at that last line (it returns previous line instead of what we expect). Here's the updated patch, now your example works as expected:
@@ -389,17 +389,11 @@ USER-POS is the cursor position (for verification only)."
(save-excursion
(widen)
(goto-char (point-min))
- (if (= (line-end-position line) (1- (point-max)))
- ; special case if the last line is empty
- (progn
- (goto-char (point-max))
- (newline)
- (forward-char -1))
- (forward-line line)
- (forward-char col))
-
- ; remove common prefix
- (let* ((cur-line (s-chop-suffix "\n" (or (thing-at-point 'line) "")))
+ (forward-line line)
+ (forward-char col)
+
+ ;; remove common prefix
+ (let* ((cur-line (buffer-substring-no-properties (line-beginning-position) (line-end-position)))
(common-prefix-len (length (s-shared-start completion cur-line))))
(setq completion (substring completion common-prefix-len))
(forward-char common-prefix-len))
from copilot.el.
It seems that the problem comes from these lines:
(if (= (line-end-position line) (1- (point-max)))
; special case if the last line is empty
(progn
(goto-char (point-max))
(newline)
(forward-char -1))
(forward-line line)
(forward-char col))
Do we actually need this special case? I tested removing it and everything worked fine for me:
@@ -389,14 +389,8 @@ USER-POS is the cursor position (for verification only)."
(save-excursion
(widen)
(goto-char (point-min))
- (if (= (line-end-position line) (1- (point-max)))
- ; special case if the last line is empty
- (progn
- (goto-char (point-max))
- (newline)
- (forward-char -1))
- (forward-line line)
- (forward-char col))
+ (forward-line line)
+ (forward-char col)
; remove common prefix
(let* ((cur-line (s-chop-suffix "\n" (or (thing-at-point 'line) "")))
(my Emacs version is 30.0.50)
from copilot.el.
@Rogach
In the screenshot, my cursor is on the second line while this file has only one line. With the special case, copilot.el can provide completions in this situation, otherwise, you will see an "End of buffer" message.
While creating new lines for users may seem strange, being able to show completions at the ends of files is useful. Any better workaround is welcome.
from copilot.el.
@Rogach Patch applied. Thanks for your elegant solution!
from copilot.el.
Related Issues (20)
- Out-of-order characters with typescript-mode when electric-indent-mode is activated and an active suggestion is shown HOT 6
- Sometimes, copilot.el's overlay is not considered an active overlay (and thus, the copilot-completion-map is not active) HOT 13
- copilot-indentation-alist requires the indent value to be a symbol HOT 4
- Change the org icon? HOT 11
- Auto balance s expressions HOT 2
- Copilot fails at login HOT 1
- jsonrpc process connection error HOT 2
- Latest commit (f8283e4) causes runtime exception: (wrong-type-argument package-desc nil) HOT 3
- PR #259 breaks startup HOT 4
- copilot--on-doc-close attempts to start the copilot agent, failing on tramp HOT 2
- Documentation seems to be missing `f` dependency in installation instructions HOT 1
- Error when used in combination with dashboard showing bookmarks HOT 6
- How to hide *copilot events* buffer when copilot-log-max is 0 HOT 2
- Warning (copilot): copilot--infer-indentation-offset found no mode-specific indentation offset. HOT 4
- Can I use a token for authentication? HOT 3
- Documentation surrounding how the language is detected seems incomplete in light of recent commit
- copilot-mode hangs and then prevents buffer from being foregrounded HOT 2
- Copilot MaxListenersExceededWarning, stops working
- How to prevent copilot from trying to write comments
- error duing `copilot--on-doc-change` in vertico completions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from copilot.el.