Skip to content

Drag and drop of a file in IDE also adds its path as string to editor #2723

Closed as not planned
@maarten-pennings

Description

@maarten-pennings

Describe the problem

The IDE is open, showing one or more files in the code pane. Each file is in its own tab, one tab/file has focus. From the file explorer I drag and drop a file in the code pane.

Two actions happen:

  • A new tab is created, the dropped file is loaded into that tab, the tab is given focus. The tab is decorated by a lock. This is the wanted action.
  • The tab that was in focus just before the drop is "edited"; it gets characters added, namely the full path of the file dropped. This is unwanted behavior.

Why would you want to drop a file? For example to inspect the source code of a used library, maybe even to put a breakpoint there for a debug session.

To reproduce

  1. Select File > New Sketch from the Arduino IDE menus.
    • A new sketch will open in an Arduino IDE window.
    • The fault is not specific to new sketches. This procedure was chosen arbitrarily as an easy way to create a simple sketch with known content.
  2. Create a text file at any path outside the sketch folder.
    The fault also occurs with a file inside the sketch folder, but the use of a file outside the folder is chosen arbitrarily for the sake of avoiding the introduction of irrelevant complications in the demo.
  3. Open your file manager application.
  4. Navigate to the location of the file you created in step 2.
  5. Drag the file to the Arduino IDE window and hover it over the editor view.
    You will see a visual indicator of five vertical dots in the editor at the position over which the mouse pointer is hovering:
    Image
  6. Drop the file from the file manager to the Arduino IDE editor view.
    🙂 The file is opened in an editor tab, as expected.
  7. Select the editor tab that was selected at the time you performed the drag and drop.

🐛 Text consisting of the path to the dropped file has been added to the content of the editor at the mouse pointer position at the time of the drop.

For example, if the path of the dropped file is c:\Users\foo\Documents\Arduino\libraries\Stepper\src\Stepper.cpp, then the editor will now contain the following content:

void setup() {
  // put your setup code here, to run once:

}
c:\Users\per\Documents\Arduino\libraries\Stepper\src\Stepper.cpp
void loop() {
  // put your main code here, to run repeatedly:

}

Expected behavior

I expect the dropped file to be added (which happens).
I do not expect text to be added to the contents of other files.

Arduino IDE version

Original report

0f9f0d0

Operating system

Windows

Operating system version

  • 10 Enterprise, Version 22H2, OS build 19045.5737, Windows Feature Experience Pack 1000.19061.1000.0
  • 11

Additional context

Workaround

Drop the file on the tab bar instead of the editor view.

-OR-

If you want to continue to drop files onto the editor view:

  1. Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
    A menu will appear on the editor toolbar:
    Command Palette
  2. Select the "Preferences: Open Settings (UI)" command from the menu.
    You can scroll down through the list of commands to find it or type the name in the field.
    A "Settings" tab will open in the Arduino IDE main panel.
  3. Type editor.dropIntoEditor.enabled in the "Search Settings" field of the "Settings" tab.
  4. Uncheck the box under the "Editor › Drop Into Editor: Enabled" setting.
  5. Close the Preferences tab by clicking its X icon.

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

Labels

conclusion: off topicOff topic for this repositorytopic: theiaRelated to the Theia IDE frameworktype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions