Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: dart/site/try/src/interaction_manager.dart

Issue 285043003: Two related changes that both affect how cursor positions might change on single line edits. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r36207. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/site/try/src/selection.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library trydart.interaction_manager; 5 library trydart.interaction_manager;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 8
9 import 'dart:convert' show 9 import 'dart:convert' show
10 JSON; 10 JSON;
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 313
314 if (normalizedNodes.length == 1) { 314 if (normalizedNodes.length == 1) {
315 Node node = normalizedNodes.single; 315 Node node = normalizedNodes.single;
316 if (node is Element && node.classes.contains('lineNumber')) { 316 if (node is Element && node.classes.contains('lineNumber')) {
317 print('Single line change: ${node.outerHtml}'); 317 print('Single line change: ${node.outerHtml}');
318 318
319 removeShadowRootPolyfill(node); 319 removeShadowRootPolyfill(node);
320 320
321 String currentText = node.text; 321 String currentText = node.text;
322 322
323 trySelection = new TrySelection(node, selection); 323 trySelection = trySelection.copyWithRoot(node);
324 trySelection.updateText(currentText); 324 trySelection.updateText(currentText);
325 325
326 editor.isMalformedInput = false; 326 editor.isMalformedInput = false;
327 int offset = 0; 327 int offset = 0;
328 List<Node> nodes = <Node>[]; 328 List<Node> nodes = <Node>[];
329 329
330 String state = ''; 330 String state = '';
331 Element previousLine = node.previousElementSibling; 331 Element previousLine = node.previousElementSibling;
332 if (previousLine != null) { 332 if (previousLine != null) {
333 state = previousLine.getAttribute('dart-state'); 333 state = previousLine.getAttribute('dart-state');
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 token.start == '"""' || 913 token.start == '"""' ||
914 token.start == "r'''" || 914 token.start == "r'''" ||
915 token.start == 'r"""'; 915 token.start == 'r"""';
916 } 916 }
917 917
918 void normalizeMutationRecord(MutationRecord record, 918 void normalizeMutationRecord(MutationRecord record,
919 TrySelection selection, 919 TrySelection selection,
920 Set<Node> normalizedNodes) { 920 Set<Node> normalizedNodes) {
921 for (Node node in record.addedNodes) { 921 for (Node node in record.addedNodes) {
922 if (node.parent == null) continue; 922 if (node.parent == null) continue;
923 normalizedNodes.add(findLine(node));
924 if (node is Text) continue;
923 StringBuffer buffer = new StringBuffer(); 925 StringBuffer buffer = new StringBuffer();
924 int selectionOffset = htmlToText(node, buffer, selection); 926 int selectionOffset = htmlToText(node, buffer, selection);
925 Text newNode = new Text('$buffer'); 927 Text newNode = new Text('$buffer');
926 node.replaceWith(newNode); 928 node.replaceWith(newNode);
927 normalizedNodes.add(findLine(newNode));
928 if (selectionOffset != -1) { 929 if (selectionOffset != -1) {
929 selection.anchorNode = newNode; 930 selection.anchorNode = newNode;
930 selection.anchorOffset = selectionOffset; 931 selection.anchorOffset = selectionOffset;
931 } 932 }
932 } 933 }
933 if (!record.removedNodes.isEmpty) { 934 if (!record.removedNodes.isEmpty) {
934 normalizedNodes.add(findLine(record.target)); 935 normalizedNodes.add(findLine(record.target));
935 } 936 }
936 if (record.type == "characterData") { 937 if (record.type == "characterData") {
937 normalizedNodes.add(findLine(record.target)); 938 normalizedNodes.add(findLine(record.target));
(...skipping 30 matching lines...) Expand all
968 return text.split(new RegExp('^', multiLine: true)); 969 return text.split(new RegExp('^', multiLine: true));
969 } 970 }
970 971
971 void removeCodeCompletion() { 972 void removeCodeCompletion() {
972 List<Node> highlighting = 973 List<Node> highlighting =
973 mainEditorPane.querySelectorAll('.dart-code-completion'); 974 mainEditorPane.querySelectorAll('.dart-code-completion');
974 for (Element element in highlighting) { 975 for (Element element in highlighting) {
975 element.remove(); 976 element.remove();
976 } 977 }
977 } 978 }
OLDNEW
« no previous file with comments | « no previous file | dart/site/try/src/selection.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698