Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sodium
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Frans Klaver
sodium
Commits
5ab21915
Commit
5ab21915
authored
7 years ago
by
Jeremy Soller
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #67 from DurgaMa/fix-0g-panic
Fix a panic when doing 0g
parents
5be6e1b2
5690ad30
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/exec.rs
+51
-33
51 additions, 33 deletions
src/core/exec.rs
with
51 additions
and
33 deletions
src/core/exec.rs
+
51
−
33
View file @
5ab21915
...
@@ -23,38 +23,44 @@ impl Editor {
...
@@ -23,38 +23,44 @@ impl Editor {
(
Primitive
(
Prompt
),
Char
(
' '
))
if
self
.key_state.shift
=>
{
(
Primitive
(
Prompt
),
Char
(
' '
))
if
self
.key_state.shift
=>
{
self
.prompt
=
String
::
new
();
self
.prompt
=
String
::
new
();
self
.cursor_mut
()
.mode
=
Mode
::
Command
(
CommandMode
::
Normal
);
self
.cursor_mut
()
.mode
=
Mode
::
Command
(
CommandMode
::
Normal
);
}
,
}
(
Primitive
(
Insert
(
_
)),
Char
(
' '
))
if
self
.key_state.shift
=>
{
(
Primitive
(
Insert
(
_
)),
Char
(
' '
))
if
self
.key_state.shift
=>
{
let
left
=
self
.left
(
1
);
let
left
=
self
.left
(
1
);
self
.goto
(
left
);
self
.goto
(
left
);
self
.cursor_mut
()
.mode
=
Mode
::
Command
(
CommandMode
::
Normal
);
self
.cursor_mut
()
.mode
=
Mode
::
Command
(
CommandMode
::
Normal
);
},
}
(
_
,
Char
(
' '
))
if
self
.key_state.shift
=>
(
_
,
Char
(
' '
))
if
self
.key_state.shift
=>
{
self
.cursor_mut
()
.mode
=
Mode
::
Command
(
CommandMode
::
Normal
),
self
.cursor_mut
()
.mode
=
Mode
::
Command
(
CommandMode
::
Normal
)
}
(
_
,
Char
(
' '
))
if
self
.key_state.alt
=>
self
.next_cursor
(),
(
_
,
Char
(
' '
))
if
self
.key_state.alt
=>
self
.next_cursor
(),
_
if
self
.key_state.alt
=>
if
let
Some
(
m
)
=
self
.to_motion
(
Inst
(
para
,
cmd
))
{
_
if
self
.key_state.alt
=>
{
self
.goto
(
m
);
if
let
Some
(
m
)
=
self
.to_motion
(
Inst
(
para
,
cmd
))
{
},
self
.goto
(
m
);
}
}
(
Command
(
Normal
),
Char
(
'i'
))
=>
{
(
Command
(
Normal
),
Char
(
'i'
))
=>
{
self
.cursor_mut
()
.mode
=
self
.cursor_mut
()
.mode
=
Mode
::
Primitive
(
PrimitiveMode
::
Insert
(
InsertOptions
{
Mode
::
Primitive
(
PrimitiveMode
::
Insert
(
InsertOptions
{
mode
:
InsertMode
::
Insert
,
mode
:
InsertMode
::
Insert
,
}));
}));
}
}
(
Command
(
Normal
),
Char
(
'a'
))
=>
{
(
Command
(
Normal
),
Char
(
'a'
))
=>
{
let
pos
=
self
.right
(
1
,
false
);
let
pos
=
self
.right
(
1
,
false
);
self
.goto
(
pos
);
self
.goto
(
pos
);
self
.cursor_mut
()
.mode
=
self
.cursor_mut
()
.mode
=
Mode
::
Primitive
(
PrimitiveMode
::
Insert
(
InsertOptions
{
Mode
::
Primitive
(
PrimitiveMode
::
Insert
(
InsertOptions
{
mode
:
InsertMode
::
Insert
,
mode
:
InsertMode
::
Insert
,
}));
}));
}
}
(
Command
(
Normal
),
Char
(
'o'
))
=>
{
(
Command
(
Normal
),
Char
(
'o'
))
=>
{
let
y
=
self
.y
();
let
y
=
self
.y
();
let
ind
=
if
self
.options.autoindent
{
let
ind
=
if
self
.options.autoindent
{
self
.buffers
.current_buffer
()
.get_indent
(
y
)
.to_owned
()
self
.buffers
.current_buffer
()
.get_indent
(
y
)
.to_owned
()
}
else
{
}
else
{
String
::
new
()
String
::
new
()
};
};
...
@@ -63,8 +69,8 @@ impl Editor {
...
@@ -63,8 +69,8 @@ impl Editor {
self
.goto
((
last
,
y
+
1
));
self
.goto
((
last
,
y
+
1
));
self
.cursor_mut
()
.mode
=
self
.cursor_mut
()
.mode
=
Mode
::
Primitive
(
PrimitiveMode
::
Insert
(
InsertOptions
{
Mode
::
Primitive
(
PrimitiveMode
::
Insert
(
InsertOptions
{
mode
:
InsertMode
::
Insert
,
mode
:
InsertMode
::
Insert
,
}));
}));
}
}
(
Command
(
Normal
),
Char
(
'h'
))
=>
{
(
Command
(
Normal
),
Char
(
'h'
))
=>
{
let
left
=
self
.left
(
n
);
let
left
=
self
.left
(
n
);
...
@@ -129,8 +135,8 @@ impl Editor {
...
@@ -129,8 +135,8 @@ impl Editor {
(
Command
(
Normal
),
Char
(
'R'
))
=>
{
(
Command
(
Normal
),
Char
(
'R'
))
=>
{
self
.cursor_mut
()
.mode
=
self
.cursor_mut
()
.mode
=
Mode
::
Primitive
(
PrimitiveMode
::
Insert
(
InsertOptions
{
Mode
::
Primitive
(
PrimitiveMode
::
Insert
(
InsertOptions
{
mode
:
InsertMode
::
Replace
,
mode
:
InsertMode
::
Replace
,
}));
}));
}
}
(
Command
(
Normal
),
Char
(
'd'
))
=>
{
(
Command
(
Normal
),
Char
(
'd'
))
=>
{
let
ins
=
self
.get_inst
();
let
ins
=
self
.get_inst
();
...
@@ -145,7 +151,7 @@ impl Editor {
...
@@ -145,7 +151,7 @@ impl Editor {
}
}
(
Command
(
Normal
),
Char
(
'g'
))
=>
{
(
Command
(
Normal
),
Char
(
'g'
))
=>
{
if
let
Parameter
::
Int
(
n
)
=
para
{
if
let
Parameter
::
Int
(
n
)
=
para
{
self
.goto
((
0
,
n
-
1
));
self
.goto
((
0
,
n
.wrapping_sub
(
1
)
));
mov
=
true
;
mov
=
true
;
}
else
{
}
else
{
let
inst
=
self
.get_inst
();
let
inst
=
self
.get_inst
();
...
@@ -158,24 +164,35 @@ impl Editor {
...
@@ -158,24 +164,35 @@ impl Editor {
}
}
(
Command
(
Normal
),
Char
(
'b'
))
=>
{
(
Command
(
Normal
),
Char
(
'b'
))
=>
{
// Branch cursor
// Branch cursor
if
self
.buffers
.current_buffer_info
()
.cursors
.len
()
<
255
{
if
self
.buffers
.current_buffer_info
()
.cursors
.len
()
<
255
{
let
cursor
=
self
.cursor
()
.clone
();
let
cursor
=
self
.cursor
()
.clone
();
let
current_cursor_index
=
self
.buffers
.current_buffer_info
()
.current_cursor
as
usize
;
let
current_cursor_index
=
self
.buffers
.current_buffer_info
()
.current_cursor
as
self
.buffers
.current_buffer_info_mut
()
.cursors
.insert
(
current_cursor_index
,
cursor
);
usize
;
self
.buffers
.current_buffer_info_mut
()
.cursors
.insert
(
current_cursor_index
,
cursor
);
self
.next_cursor
();
self
.next_cursor
();
}
}
else
{
else
{
self
.status_bar.msg
=
format!
(
"At max 255 cursors"
);
self
.status_bar.msg
=
format!
(
"At max 255 cursors"
);
}
}
}
}
(
Command
(
Normal
),
Char
(
'B'
))
=>
{
(
Command
(
Normal
),
Char
(
'B'
))
=>
{
// Delete cursor
// Delete cursor
if
self
.buffers
.current_buffer_info
()
.cursors
.len
()
>
1
{
if
self
.buffers
.current_buffer_info
()
.cursors
.len
()
>
1
{
let
current_cursor_index
=
self
.buffers
.current_buffer_info
()
.current_cursor
;
let
current_cursor_index
=
self
.buffers
.current_buffer_info
()
.current_cursor
;
self
.buffers
.current_buffer_info_mut
()
.cursors
.remove
(
current_cursor_index
as
usize
);
self
.buffers
.current_buffer_info_mut
()
.cursors
.remove
(
current_cursor_index
as
usize
);
self
.prev_cursor
();
self
.prev_cursor
();
}
}
else
{
else
{
self
.status_bar.msg
=
format!
(
"No other cursors!"
);
self
.status_bar.msg
=
format!
(
"No other cursors!"
);
}
}
}
}
...
@@ -207,8 +224,9 @@ impl Editor {
...
@@ -207,8 +224,9 @@ impl Editor {
mov
=
true
;
mov
=
true
;
}
}
}
}
(
Command
(
Normal
),
Char
(
';'
))
=>
(
Command
(
Normal
),
Char
(
';'
))
=>
{
self
.cursor_mut
()
.mode
=
Mode
::
Primitive
(
PrimitiveMode
::
Prompt
),
self
.cursor_mut
()
.mode
=
Mode
::
Primitive
(
PrimitiveMode
::
Prompt
)
}
(
Command
(
Normal
),
Char
(
' '
))
=>
self
.next_cursor
(),
(
Command
(
Normal
),
Char
(
' '
))
=>
self
.next_cursor
(),
(
Command
(
Normal
),
Char
(
'z'
))
=>
{
(
Command
(
Normal
),
Char
(
'z'
))
=>
{
let
Inst
(
param
,
cmd
)
=
self
.get_inst
();
let
Inst
(
param
,
cmd
)
=
self
.get_inst
();
...
@@ -254,19 +272,19 @@ impl Editor {
...
@@ -254,19 +272,19 @@ impl Editor {
}
else
{
}
else
{
self
.status_bar.msg
=
format!
(
"Unknown command: {}"
,
self
.prompt
);
self
.status_bar.msg
=
format!
(
"Unknown command: {}"
,
self
.prompt
);
}
}
}
,
}
(
Primitive
(
Prompt
),
Backspace
)
=>
{
(
Primitive
(
Prompt
),
Backspace
)
=>
{
self
.prompt
.pop
();
self
.prompt
.pop
();
self
.redraw_task
=
RedrawTask
::
StatusBar
;
self
.redraw_task
=
RedrawTask
::
StatusBar
;
}
,
}
(
Primitive
(
Prompt
),
Char
(
c
))
=>
{
(
Primitive
(
Prompt
),
Char
(
c
))
=>
{
self
.prompt
.push
(
c
);
self
.prompt
.push
(
c
);
self
.redraw_task
=
RedrawTask
::
StatusBar
;
self
.redraw_task
=
RedrawTask
::
StatusBar
;
}
,
}
_
=>
{
_
=>
{
self
.status_bar.msg
=
format!
(
"Unknown command"
);
self
.status_bar.msg
=
format!
(
"Unknown command"
);
self
.redraw_task
=
RedrawTask
::
StatusBar
;
self
.redraw_task
=
RedrawTask
::
StatusBar
;
}
,
}
}
}
if
mov
{
if
mov
{
self
.redraw_task
=
RedrawTask
::
Cursor
(
bef
,
self
.pos
());
self
.redraw_task
=
RedrawTask
::
Cursor
(
bef
,
self
.pos
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment