Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » delete stops working within editor plugin under development(delete key stops working sporadically, only on Windows OS, when using the editor that is part of the plugin we are developing)
delete stops working within editor plugin under development [message #1798646] Wed, 21 November 2018 23:02 Go to next message
Andrew Williams is currently offline Andrew WilliamsFriend
Messages: 2
Registered: November 2018
Junior Member
We are developing a markdown editor plugin for eclipse. When using Windows 10 we encounter a bug that causes keys to stop working. The most common key is delete, other times it is ctrl + s.

Here is the code for the editor extension:
public class MarkdownEditor extends AbstractTextEditor {

private Activator activator;
private MarkdownRenderer markdownRenderer;
private IWebBrowser browser;

public MarkdownEditor() throws FileNotFoundException {

    setSourceViewerConfiguration(new TextSourceViewerConfiguration());

    setDocumentProvider(new TextFileDocumentProvider());

    // Activator manages connections to the Workbench
    activator = Activator.getDefault();

    markdownRenderer = new MarkdownRenderer();

private IFile saveMarkdown(IEditorInput editorInput, IDocument document, IProgressMonitor progressMonitor) {
    IProject project = getCurrentProject(editorInput);

    String mdFileName = editorInput.getName();
    String fileName = mdFileName.substring(0, mdFileName.lastIndexOf('.'));
    String htmlFileName = fileName + ".html";
    IFile file = project.getFile(htmlFileName);

    String markdownString = "<!DOCTYPE html>\n" + "<html>" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>"
            + htmlFileName + "</title>\n" + "</head>" + "<body>" + markdownRenderer.render(document.get())
            + "</body>\n" + "</html>";
    try {
        if (!project.isOpen())
        if (file.exists())
            file.delete(true, progressMonitor);
        if (!file.exists()) {
            byte[] bytes = markdownString.getBytes();
            InputStream source = new ByteArrayInputStream(bytes);
            file.create(source, IResource.NONE, progressMonitor);
    } catch (CoreException e) {
        // TODO Auto-generated catch block
    return file;

private void loadFileInBrowser(IFile file) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    try {
        if (browser == null)
            browser = workbench.getBrowserSupport().createBrowser(Activator.PLUGIN_ID);
        URL htmlFile = FileLocator.toFileURL(file.getLocationURI().toURL());
        IWorkbenchPartSite site = this.getSite();
        IWorkbenchPart part = site.getPart();
    } catch (IOException | PartInitException e) {

public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
    super.init(site, editorInput);
    IDocumentProvider documentProvider = getDocumentProvider();
    IDocument document = documentProvider.getDocument(editorInput);
    IFile htmlFile = saveMarkdown(editorInput, document, null);

public void doSave(IProgressMonitor progressMonitor) {

    IDocumentProvider documentProvider = getDocumentProvider();
    if (documentProvider == null)
    IEditorInput editorInput = getEditorInput();
    IDocument document = documentProvider.getDocument(editorInput);
    if (documentProvider.isDeleted(getEditorInput())) {

        if (isSaveAsAllowed()) {

             * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors.
             * Changed Behavior to make sure that if called inside a regular save (because
             * of deletion of input element) there is a way to report back to the caller.

        } else {


    } else {
        // Convert document from string to string array with each instance a single line
        // of the document
        String[] stringArrayOfDocument = document.get().split("\n");
        String[] formattedLines = PipeTableFormat.preprocess(stringArrayOfDocument);
        StringBuilder builder = new StringBuilder();
        for (String line : formattedLines) {
        String formattedDocument = builder.toString();

        // Calculating the position of the cursor
        ISelectionProvider selectionProvider = this.getSelectionProvider();
        ISelection selection = selectionProvider.getSelection();
        int cursorLength = 0;
        if (selection instanceof ITextSelection) {
            ITextSelection textSelection = (ITextSelection) selection;
            cursorLength = textSelection.getOffset(); // etc.
        // This sets the cursor on at the start of the file

        // Move the cursor
        this.setHighlightRange(cursorLength, 0, true);
        IFile htmlFile = saveMarkdown(editorInput, document, progressMonitor);
        performSave(false, progressMonitor);

private IProject getCurrentProject(IEditorInput editorInput) {
    IProject project = editorInput.getAdapter(IProject.class);
    if (project == null) {
        IResource resource = editorInput.getAdapter(IResource.class);
        if (resource != null) {
            project = resource.getProject();
    return project;

Here is the repository:

Thank you for any help you are able to offer!
Re: delete stops working within editor plugin under development [message #1798702 is a reply to message #1798646] Fri, 23 November 2018 01:38 Go to previous message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 142
Registered: March 2018
Senior Member
Is your software written using an operating system that standardizes on Unix-8? Check output from several different kinds of streams on the new Microsoft system. is probably the root of your problem. Sending a 32-bit number when a 64-bit number is expected will produce errors. Sending a 64-bit number when a 32 bit-ter is expected will also cause problems.

Maybe you can catch your keyboard or software-generated commands as they enter the software on the Windows systems and compare that with what happens when a Windows-10 native app sends the same problematical commands. If you are sending a 32-bit backspace when the Windows keyboard would send 64-bit backspace information, maybe the Windows system as currently written does not catch and correct it.

I would try doing hex dumps on any kind of data you can capture and maintain in its true form.
Previous Topic:Missing Web Tools on Eclipse for Java
Next Topic:Porting from C++ code BCM2837 to BCM2835
Goto Forum:

Current Time: Wed Feb 19 03:39:52 GMT 2020

Powered by FUDForum. Page generated in 0.03006 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top