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

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

Issue 212823002: Don't loop forever on scanner errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix long line that Kasper missed :-) Created 6 years, 9 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 Decoration decoration = editor.getDecoration(token); 253 Decoration decoration = editor.getDecoration(token);
254 if (decoration == null) continue; 254 if (decoration == null) continue;
255 bool hasSelection = false; 255 bool hasSelection = false;
256 int selectionOffset = selection.anchorOffset; 256 int selectionOffset = selection.anchorOffset;
257 257
258 if (selection.isCollapsed && selection.anchorNode == node) { 258 if (selection.isCollapsed && selection.anchorNode == node) {
259 hasSelection = true; 259 hasSelection = true;
260 selectionOffset = selection.anchorOffset; 260 selectionOffset = selection.anchorOffset;
261 } 261 }
262 int splitPoint = token.charOffset - offset; 262 int splitPoint = token.charOffset - offset;
263 if (splitPoint < 0) continue; // Happens for scanner errors.
263 Text str = node.splitText(splitPoint); 264 Text str = node.splitText(splitPoint);
264 Text after = str.splitText(token.charCount); 265 Text after = str.splitText(token.charCount);
265 offset += splitPoint + token.charCount; 266 offset += splitPoint + token.charCount;
266 mainEditorPane.insertBefore(after, node.nextNode); 267 mainEditorPane.insertBefore(after, node.nextNode);
267 mainEditorPane.insertBefore(decoration.applyTo(str), after); 268 mainEditorPane.insertBefore(decoration.applyTo(str), after);
268 269
269 if (hasSelection && selectionOffset > node.length) { 270 if (hasSelection && selectionOffset > node.length) {
270 selectionOffset -= node.length; 271 selectionOffset -= node.length;
271 if (selectionOffset > str.length) { 272 if (selectionOffset > str.length) {
272 selectionOffset -= str.length; 273 selectionOffset -= str.length;
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 event.getModifierState("Fn") || 593 event.getModifierState("Fn") ||
593 event.getModifierState("Meta") || 594 event.getModifierState("Meta") ||
594 event.getModifierState("NumLock") || 595 event.getModifierState("NumLock") ||
595 event.getModifierState("ScrollLock") || 596 event.getModifierState("ScrollLock") ||
596 event.getModifierState("Scroll") || 597 event.getModifierState("Scroll") ||
597 event.getModifierState("Win") || 598 event.getModifierState("Win") ||
598 event.getModifierState("Shift") || 599 event.getModifierState("Shift") ||
599 event.getModifierState("SymbolLock") || 600 event.getModifierState("SymbolLock") ||
600 event.getModifierState("OS"); 601 event.getModifierState("OS");
601 } 602 }
OLDNEW
« no previous file with comments | « no previous file | dart/tests/try/paste_content_rewriting_test.dart » ('j') | dart/tests/try/paste_content_rewriting_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698