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

Save feature is bugged #58

Open
maxxber opened this issue Sep 9, 2024 · 4 comments
Open

Save feature is bugged #58

maxxber opened this issue Sep 9, 2024 · 4 comments

Comments

@maxxber
Copy link

maxxber commented Sep 9, 2024

Hello, I'm studying the tutorial and I arrived to step 130;
I have a big problem with the implementation of saving feature:
every time I save a file and reopen it, the first line of text is missing and the rest of the content goes up by one line.

Do you have the same experience? Do you have any ideas of what part of the program needs fixing?

@maxxber
Copy link
Author

maxxber commented Sep 9, 2024

This is the source code updated at step 130:
kilo.txt

@maxxber
Copy link
Author

maxxber commented Sep 9, 2024

I'm trying to spot if I did a typing mistake, I saw there is a "steps.diff" file with all the code entries: how to use it?
steps.txt

It would be ideal if I can obtain the original source code of the tutorial with all the steps reproduced till step 130 and check the differences with my source code...

@paigeruten
Copy link
Contributor

Hi @maxxber, the source code of each step of the tutorial is contained in this repo: https://github.com/snaptoken/kilo-src. The readme shows an example of how to do a diff with your code with whitespace disabled.

You can get to the source code for a specific step from the tutorial by clicking on the step name in the upper-right corner of the diff for that step. Here is the code for step 130: https://github.com/snaptoken/kilo-src/blob/prompt-backspace/kilo.c

Let me know if that helps, and I'm happy to take a closer look at your code a little later if you are still stuck 🙂

@maxxber
Copy link
Author

maxxber commented Sep 10, 2024

Hello @paigeruten, thank you very much for your explanation, it helped a lot!

I compared the source codes with WinMerge and I saw that I left two portions of code belonging to previous steps:

  • a call to function editorReadKey() in getWindowSize function;
  • an assignment of linelen = getline(&line, &linecap, fp); in editorOpen function.

After removing this couple of code lines the saving function started to work properly! 😊

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

2 participants