Ejemplo n.º 1
0
  private void init(
      final int visibleWidth,
      @NotNull String fileText,
      @NotNull TestFileType fileType,
      final int symbolWidth)
      throws IOException {
    init(fileText, fileType);
    myEditor.getSettings().setUseSoftWraps(true);
    SoftWrapModelImpl model = (SoftWrapModelImpl) myEditor.getSoftWrapModel();
    model.reinitSettings();

    SoftWrapApplianceManager applianceManager = model.getApplianceManager();
    applianceManager.setWidthProvider(
        new SoftWrapApplianceManager.VisibleAreaWidthProvider() {
          @Override
          public int getVisibleAreaWidth() {
            return visibleWidth;
          }
        });

    if (symbolWidth > 0) {
      model.setEditorTextRepresentationHelper(
          new DefaultEditorTextRepresentationHelper(myEditor) {
            @Override
            public int charWidth(char c, int fontType) {
              return symbolWidth;
            }
          });
    }

    applianceManager.registerSoftWrapIfNecessary();
  }
Ejemplo n.º 2
0
 public void testNoUnnecessaryHorizontalScrollBar() throws IOException {
   // Inspired by IDEA-87184
   final String text = "12345678 abcdefgh";
   init(15, 7, text);
   myEditor.getCaretModel().moveToOffset(text.length());
   final Ref<Boolean> fail = new Ref<Boolean>(true);
   SoftWrapApplianceManager applianceManager =
       ((SoftWrapModelImpl) myEditor.getSoftWrapModel()).getApplianceManager();
   SoftWrapAwareDocumentParsingListener listener =
       new SoftWrapAwareDocumentParsingListenerAdapter() {
         @Override
         public void beforeSoftWrapLineFeed(@NotNull EditorPosition position) {
           if (position.x == text.indexOf("a") * 7) {
             fail.set(false);
           }
         }
       };
   applianceManager.addListener(listener);
   try {
     backspace();
   } finally {
     applianceManager.removeListener(listener);
   }
   assertFalse(fail.get());
 }