~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/core/Mono.Texteditor/Mono.TextEditor/Actions/DeleteActions.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
168
168
                        if (!data.CanEditSelection)
169
169
                                return;
170
170
                        if (data.IsSomethingSelected) {
 
171
                                var visualAnchorLocation = data.LogicalToVisualLocation (data.MainSelection.Anchor);
 
172
                                var visualLeadLocation = data.LogicalToVisualLocation (data.MainSelection.Lead);
171
173
                                // case: zero width block selection
172
 
                                if (data.MainSelection.SelectionMode == SelectionMode.Block && data.MainSelection.Anchor.Column == data.MainSelection.Lead.Column) {
 
174
                                if (data.MainSelection.SelectionMode == SelectionMode.Block && visualAnchorLocation.Column == visualLeadLocation.Column) {
173
175
                                        var col = data.MainSelection.Lead.Column;
174
176
                                        if (col <= DocumentLocation.MinColumn) {
175
177
                                                data.ClearSelection ();
177
179
                                        }
178
180
                                        bool preserve = data.Caret.PreserveSelection;
179
181
                                        data.Caret.PreserveSelection = true;
180
 
                                        col--;
181
182
                                        for (int lineNumber = data.MainSelection.MinLine; lineNumber <= data.MainSelection.MaxLine; lineNumber++) {
182
 
                                                data.Remove (data.Document.GetLine (lineNumber).Offset + col - 1, 1);
 
183
                                                var lineSegment = data.Document.GetLine (lineNumber);
 
184
                                                int insertOffset = lineSegment.GetLogicalColumn (data, visualAnchorLocation.Column - 1) - 1;
 
185
                                                data.Remove (lineSegment.Offset + insertOffset, 1);
183
186
                                        }
184
 
                                        data.MainSelection.Lead = new DocumentLocation (data.MainSelection.Lead.Line, col);
185
 
                                        data.MainSelection.Anchor = new DocumentLocation (data.MainSelection.Anchor.Line, col);
 
187
 
 
188
                                        var visualColumn = data.GetLine (data.Caret.Location.Line).GetVisualColumn (data, col - 1);
 
189
                                        data.MainSelection = new Selection (
 
190
                                                new DocumentLocation (data.MainSelection.Anchor.Line, data.GetLine (data.MainSelection.Anchor.Line).GetLogicalColumn (data, visualColumn)),
 
191
                                                new DocumentLocation (data.MainSelection.Lead.Line, data.GetLine (data.MainSelection.Lead.Line).GetLogicalColumn (data, visualColumn)),
 
192
                                                SelectionMode.Block
 
193
                                        );
 
194
 
186
195
                                        data.Caret.PreserveSelection = preserve;
187
196
                                        data.Document.CommitMultipleLineUpdate (data.MainSelection.MinLine, data.MainSelection.MaxLine);
188
197
                                        return;
202
211
                                data.Caret.Column = line.Length + 1;
203
212
                        } else if (data.Caret.Offset == line.Offset) {
204
213
                                DocumentLine lineAbove = data.Document.GetLine (data.Caret.Line - 1);
205
 
                                data.Remove (lineAbove.EndOffsetIncludingDelimiter - lineAbove.DelimiterLength, lineAbove.DelimiterLength);
 
214
                                if (lineAbove.Length == 0 && data.HasIndentationTracker && data.Options.IndentStyle == IndentStyle.Virtual) {
 
215
                                        data.Replace (lineAbove.EndOffsetIncludingDelimiter - lineAbove.DelimiterLength, lineAbove.DelimiterLength, data.IndentationTracker.GetIndentationString (data.Caret.Line - 1, 1));
 
216
                                } else {
 
217
                                        data.Remove (lineAbove.EndOffsetIncludingDelimiter - lineAbove.DelimiterLength, lineAbove.DelimiterLength);
 
218
                                }
206
219
                        } else {
207
220
                                removeCharBeforeCaret (data);
208
221
                        }
216
229
                        int offset = data.Caret.Offset;
217
230
                        if (offset <= 0)
218
231
                                return;
219
 
                        int column = data.Caret.Column;
 
232
                        var version = data.Version;
220
233
                        data.Remove (offset - 1, 1);
221
 
                        data.Caret.Column = column - 1;
 
234
                        data.Caret.Location = data.OffsetToLocation (version.MoveOffsetTo (data.Version, offset));
222
235
                }
223
236
                
224
237
                public static void Delete (TextEditorData data)