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

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: 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
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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 token.start == '"""' || 912 token.start == '"""' ||
913 token.start == "r'''" || 913 token.start == "r'''" ||
914 token.start == 'r"""'; 914 token.start == 'r"""';
915 } 915 }
916 916
917 void normalizeMutationRecord(MutationRecord record, 917 void normalizeMutationRecord(MutationRecord record,
918 TrySelection selection, 918 TrySelection selection,
919 Set<Node> normalizedNodes) { 919 Set<Node> normalizedNodes) {
920 for (Node node in record.addedNodes) { 920 for (Node node in record.addedNodes) {
921 if (node.parent == null) continue; 921 if (node.parent == null) continue;
922 normalizedNodes.add(findLine(node));
923 if (node is Text) continue;
922 StringBuffer buffer = new StringBuffer(); 924 StringBuffer buffer = new StringBuffer();
923 int selectionOffset = htmlToText(node, buffer, selection); 925 int selectionOffset = htmlToText(node, buffer, selection);
924 Text newNode = new Text('$buffer'); 926 Text newNode = new Text('$buffer');
925 node.replaceWith(newNode); 927 node.replaceWith(newNode);
926 normalizedNodes.add(findLine(newNode));
927 if (selectionOffset != -1) { 928 if (selectionOffset != -1) {
928 selection.anchorNode = newNode; 929 selection.anchorNode = newNode;
929 selection.anchorOffset = selectionOffset; 930 selection.anchorOffset = selectionOffset;
930 } 931 }
931 } 932 }
932 if (!record.removedNodes.isEmpty) { 933 if (!record.removedNodes.isEmpty) {
933 normalizedNodes.add(findLine(record.target)); 934 normalizedNodes.add(findLine(record.target));
934 } 935 }
935 if (record.type == "characterData") { 936 if (record.type == "characterData") {
936 normalizedNodes.add(findLine(record.target)); 937 normalizedNodes.add(findLine(record.target));
(...skipping 30 matching lines...) Expand all
967 return text.split(new RegExp('^', multiLine: true)); 968 return text.split(new RegExp('^', multiLine: true));
968 } 969 }
969 970
970 void removeCodeCompletion() { 971 void removeCodeCompletion() {
971 List<Node> highlighting = 972 List<Node> highlighting =
972 mainEditorPane.querySelectorAll('.dart-code-completion'); 973 mainEditorPane.querySelectorAll('.dart-code-completion');
973 for (Element element in highlighting) { 974 for (Element element in highlighting) {
974 element.remove(); 975 element.remove();
975 } 976 }
976 } 977 }
OLDNEW
« no previous file with comments | « no previous file | dart/site/try/src/selection.dart » ('j') | dart/tests/try/cursor_position_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698