fixed bug with whitespace batch editing and token fixup
parent
e07ec779cb
commit
562bd0601a
2
4ed.cpp
2
4ed.cpp
|
@ -752,6 +752,8 @@ COMMAND_DECL(delete_range){
|
||||||
view_cursor_move(view, next_cursor_pos);
|
view_cursor_move(view, next_cursor_pos);
|
||||||
view->file_data.mark = range.start;
|
view->file_data.mark = range.start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
general_memory_check(&models->mem.general);
|
||||||
}
|
}
|
||||||
|
|
||||||
COMMAND_DECL(undo){
|
COMMAND_DECL(undo){
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* Mr. 4th Dimention - Allen Webster
|
* Mr. 4th Dimention - Allen Webster
|
||||||
*
|
*
|
||||||
* 19.08.2015
|
* 19.08.2015
|
||||||
*
|
*
|
||||||
* File editing view for 4coder
|
* File editing view for 4coder
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TOP
|
// TOP
|
||||||
|
|
||||||
|
@ -1789,6 +1789,7 @@ file_do_white_batch_edit(System_Functions *system, Models *models, Editing_File
|
||||||
Cpp_Token_Stack tokens = file->state.token_stack;
|
Cpp_Token_Stack tokens = file->state.token_stack;
|
||||||
Cpp_Token *token = tokens.tokens;
|
Cpp_Token *token = tokens.tokens;
|
||||||
Cpp_Token *end_token = tokens.tokens + tokens.count;
|
Cpp_Token *end_token = tokens.tokens + tokens.count;
|
||||||
|
Cpp_Token original = {(Cpp_Token_Type)0};
|
||||||
|
|
||||||
Buffer_Edit *edit = batch;
|
Buffer_Edit *edit = batch;
|
||||||
Buffer_Edit *end_edit = batch + batch_size;
|
Buffer_Edit *end_edit = batch + batch_size;
|
||||||
|
@ -1796,21 +1797,50 @@ file_do_white_batch_edit(System_Functions *system, Models *models, Editing_File
|
||||||
i32 shift_amount = 0;
|
i32 shift_amount = 0;
|
||||||
i32 local_shift = 0;
|
i32 local_shift = 0;
|
||||||
|
|
||||||
for (; token < end_token && edit < end_edit; ++edit){
|
for (; token < end_token; ++token){
|
||||||
|
original = *token;
|
||||||
|
for (; edit < end_edit && edit->start <= original.start; ++edit){
|
||||||
local_shift = (edit->len - (edit->end - edit->start));
|
local_shift = (edit->len - (edit->end - edit->start));
|
||||||
for (; token->start < edit->start && edit->start < token->start + token->size &&
|
|
||||||
token < end_token; ++token){
|
|
||||||
token->size += local_shift;
|
|
||||||
token->start += shift_amount;
|
|
||||||
}
|
|
||||||
for (; token->start < edit->start && token < end_token; ++token){
|
|
||||||
token->start += shift_amount;
|
|
||||||
}
|
|
||||||
shift_amount += local_shift;
|
shift_amount += local_shift;
|
||||||
}
|
}
|
||||||
|
token->start += shift_amount;
|
||||||
|
local_shift = 0;
|
||||||
|
for (; edit < end_edit && edit->start < original.start + original.size; ++edit){
|
||||||
|
local_shift += (edit->len - (edit->end - edit->start));
|
||||||
|
}
|
||||||
|
token->size += local_shift;
|
||||||
|
shift_amount += local_shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
for (; token < end_token && edit < end_edit;){
|
||||||
|
local_shift = (edit->len - (edit->end - edit->start));
|
||||||
|
for (; token->start + token->size < edit->start && token < end_token; ++token){
|
||||||
|
token->start += shift_amount;
|
||||||
|
}
|
||||||
|
if (token->start <= edit->start){
|
||||||
|
original = *token;
|
||||||
|
if (original.start == edit->start){
|
||||||
|
shift_amount += local_shift;
|
||||||
|
token->start += shift_amount;
|
||||||
|
++edit;
|
||||||
|
}
|
||||||
|
for (; edit->start < original.start + original.size && edit < end_edit; ++edit){
|
||||||
|
local_shift = (edit->len - (edit->end - edit->start));
|
||||||
|
token->size += local_shift;
|
||||||
|
shift_amount += local_shift;
|
||||||
|
}
|
||||||
|
++token;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
shift_amount += local_shift;
|
||||||
|
++edit;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (; token < end_token; ++token){
|
for (; token < end_token; ++token){
|
||||||
token->start += shift_amount;
|
token->start += shift_amount;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2303,7 +2333,7 @@ compute_this_indent(Buffer *buffer, Indent_Parse_State indent,
|
||||||
next_line_start = buffer_size(buffer);
|
next_line_start = buffer_size(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev_token.type == CPP_TOKEN_COMMENT &&
|
if ((prev_token.type == CPP_TOKEN_COMMENT || prev_token.type == CPP_TOKEN_STRING_CONSTANT) &&
|
||||||
prev_token.start <= this_line_start && prev_token.start + prev_token.size > this_line_start){
|
prev_token.start <= this_line_start && prev_token.start + prev_token.size > this_line_start){
|
||||||
this_indent = previous_indent;
|
this_indent = previous_indent;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue