Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-19fa
git_rec_nano
Commits
b9638cb7
Commit
b9638cb7
authored
7 years ago
by
David Lawrence Ramsey
Committed by
Benno Schulenberg
7 years ago
Browse files
Options
Download
Email Patches
Plain Diff
undo: when adding text adds a magicline, an undo should remove both
This fixes
http://savannah.gnu.org/bugs/?52523
.
parent
d646a3b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/nano.c
+7
-7
src/nano.c
src/nano.h
+3
-2
src/nano.h
src/text.c
+7
-0
src/text.c
with
17 additions
and
9 deletions
+17
-9
src/nano.c
View file @
b9638cb7
...
...
@@ -1813,13 +1813,6 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
if
(
!
allow_cntrls
&&
is_ascii_cntrl_char
(
*
(
output
+
i
-
char_len
)))
continue
;
/* If we're adding to the magicline, create a new magicline. */
if
(
!
ISSET
(
NO_NEWLINES
)
&&
openfile
->
filebot
==
openfile
->
current
)
{
new_magicline
();
if
(
margin
>
0
)
refresh_needed
=
TRUE
;
}
/* Make room for the new character and copy it into the line. */
openfile
->
current
->
data
=
charealloc
(
openfile
->
current
->
data
,
current_len
+
char_len
+
1
);
...
...
@@ -1856,6 +1849,13 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
update_undo
(
ADD
);
#endif
/* If we've added text to the magicline, create a new magicline. */
if
(
openfile
->
filebot
==
openfile
->
current
&&
!
ISSET
(
NO_NEWLINES
))
{
new_magicline
();
if
(
margin
>
0
)
refresh_needed
=
TRUE
;
}
#ifdef ENABLE_WRAPPING
/* If text gets wrapped, the edit window needs a refresh. */
if
(
!
ISSET
(
NO_WRAP
)
&&
do_wrap
(
openfile
->
current
))
...
...
This diff is collapsed.
Click to expand it.
src/nano.h
View file @
b9638cb7
...
...
@@ -607,9 +607,10 @@ enum
/* Some extra flags for the undo function. */
#define WAS_FINAL_BACKSPACE (1<<1)
#define WAS_WHOLE_LINE (1<<2)
#define WAS_FINAL_LINE (1<<3)
/* The flags for the mark need to be the highest. */
#define MARK_WAS_SET (1<<
3
)
#define WAS_MARKED_FORWARD (1<<
4
)
#define MARK_WAS_SET (1<<
4
)
#define WAS_MARKED_FORWARD (1<<
5
)
#endif
/* !NANO_TINY */
/* The maximum number of entries displayed in the main shortcut list. */
...
...
This diff is collapsed.
Click to expand it.
src/text.c
View file @
b9638cb7
...
...
@@ -734,6 +734,8 @@ void do_undo(void)
/* TRANSLATORS: The next twelve strings describe actions
* that are undone or redone. It are all nouns, not verbs. */
undidmsg
=
_
(
"text add"
);
if
(
u
->
xflags
==
WAS_FINAL_LINE
&&
!
ISSET
(
NO_NEWLINES
))
remove_magicline
();
data
=
charalloc
(
strlen
(
f
->
data
)
-
strlen
(
u
->
strdata
)
+
1
);
strncpy
(
data
,
f
->
data
,
u
->
begin
);
strcpy
(
&
data
[
u
->
begin
],
&
f
->
data
[
u
->
begin
+
strlen
(
u
->
strdata
)]);
...
...
@@ -907,6 +909,8 @@ void do_redo(void)
switch
(
u
->
type
)
{
case
ADD
:
redidmsg
=
_
(
"text add"
);
if
(
u
->
xflags
==
WAS_FINAL_LINE
&&
!
ISSET
(
NO_NEWLINES
))
new_magicline
();
data
=
charalloc
(
strlen
(
f
->
data
)
+
strlen
(
u
->
strdata
)
+
1
);
strncpy
(
data
,
f
->
data
,
u
->
begin
);
strcpy
(
&
data
[
u
->
begin
],
u
->
strdata
);
...
...
@@ -1272,6 +1276,9 @@ void add_undo(undo_type action)
/* We need to start copying data into the undo buffer
* or we won't be able to restore it later. */
case
ADD
:
/* If a new magic line will be added, an undo should remove it. */
if
(
openfile
->
current
==
openfile
->
filebot
&&
openfile
->
current_x
==
0
)
u
->
xflags
=
WAS_FINAL_LINE
;
u
->
wassize
--
;
break
;
case
BACK
:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment